Name all tests consistently

Let all of them start with 'test_'. And move __main__.py into
__init__.py.
This commit is contained in:
Sascha Peilicke 2014-02-02 14:30:59 +01:00
parent 4d63ecfe25
commit 1097d95215
10 changed files with 35 additions and 37 deletions

@ -4,4 +4,4 @@ python:
- "2.7"
- "3.3"
install: "pip install --use-mirrors -r test-requirements.txt"
script: python test/__main__.py -v
script: python test/__init__.py -v

@ -0,0 +1,25 @@
"""
LessCss tests
"""
import unittest
import os
import re
import bootstrap
def find():
svn = re.compile('\.svn')
test = re.compile('test.+\.py$')
alltests = unittest.TestSuite()
for path, _, files in os.walk(bootstrap.here):
if svn.search(path):
continue
for f in files:
if test.search(f):
module = __import__(f.split('.')[0])
alltests.addTest(unittest.findTestCases(module))
return alltests
if __name__ == '__main__':
unittest.main(defaultTest='find')

@ -1,25 +0,0 @@
"""
LessCss tests
"""
import unittest
import os
import re
import bootstrap
def find():
svn = re.compile('\.svn')
test = re.compile('test.+\.py$')
alltests = unittest.TestSuite()
for path, _, files in os.walk(bootstrap.here):
if svn.search(path):
continue
for f in files:
if test.search(f):
module = __import__(f.split('.')[0])
alltests.addTest(unittest.findTestCases(module))
return alltests
if __name__ == '__main__':
unittest.main(defaultTest='find')

@ -3,7 +3,6 @@ from lesscpy.plib.expression import Expression
class TestExpression(unittest.TestCase):
def test_basic(self):
for test in [
['0', '+', '0', '0'],
@ -43,7 +42,7 @@ class TestExpression(unittest.TestCase):
e = Expression(test[:3])
self.assertEqual(test[3], e.parse(None), str(test))
def testop(self):
def test_op(self):
for test in [
['0', '=', '0', True],
['1', '>', '2', False],

@ -3,8 +3,7 @@ import lesscpy.lessc.utility as utility
class TestUtility(unittest.TestCase):
def testanalyze(self):
def test_analyze(self):
test = utility.analyze_number
self.assertEqual((0, ''), test('0'))
self.assertEqual((1, ''), test('1'))
@ -24,7 +23,7 @@ class TestUtility(unittest.TestCase):
self.assertRaises(SyntaxError, test, '-o')
self.assertRaises(SyntaxError, test, '')
def testsplit_unit(self):
def test_split_unit(self):
test = utility.split_unit
self.assertEqual(('', ''), test(None))
self.assertEqual(('', ''), test(False))
@ -34,7 +33,7 @@ class TestUtility(unittest.TestCase):
self.assertEqual(('1', 'px'), test('1px'))
self.assertEqual(('-1', 'px'), test('-1px'))
def testis_int(self):
def test_is_int(self):
test = utility.is_int
self.assertTrue(test(1))
self.assertTrue(test('1'))
@ -44,7 +43,7 @@ class TestUtility(unittest.TestCase):
self.assertFalse(test(None))
self.assertFalse(test(0.0))
def testis_float(self):
def test_is_float(self):
test = utility.is_float
self.assertFalse(test(1))
self.assertFalse(test('1'))
@ -55,7 +54,7 @@ class TestUtility(unittest.TestCase):
self.assertTrue(test('77.0565'))
self.assertTrue(test('-0.0'))
def testis_color(self):
def test_is_color(self):
test = utility.is_color
self.assertTrue(test('#123'))
self.assertTrue(test('#123456'))
@ -70,7 +69,7 @@ class TestUtility(unittest.TestCase):
self.assertFalse(test(False))
self.assertFalse(test([]))
def testis_variable(self):
def test_is_variable(self):
test = utility.is_variable
self.assertTrue(test('@var'))
self.assertTrue(test('-@var'))
@ -79,7 +78,7 @@ class TestUtility(unittest.TestCase):
self.assertFalse(test(False))
self.assertFalse(test([]))
def testwith_unit(self):
def test_with_unit(self):
test = utility.with_unit
self.assertEqual('1px', test((1, 'px')))
self.assertEqual('1px', test(1, 'px'))

@ -3,7 +3,7 @@ envlist = py26,py27,py33,flake8
[testenv]
deps = -r{toxinidir}/test-requirements.txt
commands = python test/__main__.py -v
commands = python test/__init__.py -v
[testenv:pep8]
commands = pep8 --repeat --show-source --ignore=E501 --exclude=.venv,.tox,build,dist,doc