diff --git a/.travis.yml b/.travis.yml index 6c73154e..f5b4181f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,12 @@ python: - 3.4 - 3.5 install: -- pip install -e . "flake8 >= 2.4.0" "Werkzeug >= 0.9" coverage coveralls +- pip install -rrequirements-dev.txt coveralls script: -- coverage run --source sass,sassc,sassutils setup.py test +- coverage run --source sass,sassc,sassutils -m pytest sasstests.py - flake8 . after_success: - coveralls +cache: + directories: + - $HOME/.cache/pip diff --git a/appveyor.yml b/appveyor.yml index 1ef9e176..c7d3e1a9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,15 +20,16 @@ init: - "ECHO %PYTHON%" - ps: "ls C:/Python*" install: -- "git -C %APPVEYOR_BUILD_FOLDER% submodule update --init" +- "git submodule update --init" - "%PYTHON%\\Scripts\\pip.exe --version" -- "%PYTHON%\\Scripts\\pip.exe install wheel" -- "%PYTHON%\\Scripts\\pip.exe install -e ." +- "%PYTHON%\\Scripts\\pip.exe install -rrequirements-dev.txt wheel" build: false test_script: -- "%PYTHON%\\python.exe -c \"import os,pprint;pprint.pprint(sorted(os.environ.items()))\"" -- "%PYTHON%\\python.exe setup.py test" +- '%PYTHON%\\python.exe -c "import os, pprint; pprint.pprint(sorted(os.environ.items()))"' +- "%PYTHON%\\python.exe -m pytest sasstests.py" after_test: - "%PYTHON%\\python.exe setup.py bdist_wheel" artifacts: - path: dist\* +cache: +- '%LOCALAPPDATA%\pip\cache' diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..cea5a198 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,5 @@ +-e . +coverage +flake8>=2.4.0 +pytest +werkzeug>=0.9 diff --git a/sasstests.py b/sasstests.py index 80636731..2623c294 100644 --- a/sasstests.py +++ b/sasstests.py @@ -16,6 +16,7 @@ import unittest import warnings +import pytest from six import PY3, StringIO, b, string_types, text_type from werkzeug.test import Client from werkzeug.wrappers import Response @@ -230,7 +231,7 @@ def test_compile_disallows_arbitrary_arguments(self): {'filename': 'test/a.scss'}, {'dirname': ('test', '/dev/null')}, ): - with assert_raises(TypeError) as excinfo: + with pytest.raises(TypeError) as excinfo: sass.compile(herp='derp', harp='darp', **args) msg, = excinfo.value.args assert msg == ( @@ -1172,22 +1173,9 @@ def compile_with_func(s): return result -@contextlib.contextmanager -def assert_raises(exctype): - # I want pytest.raises, this'll have to do for now - class C: - pass - - try: - yield C - assert False, 'Expected to raise!' - except exctype as e: - C.value = e - - @contextlib.contextmanager def assert_raises_compile_error(expected): - with assert_raises(sass.CompileError) as excinfo: + with pytest.raises(sass.CompileError) as excinfo: yield msg, = excinfo.value.args assert msg.decode('UTF-8') == expected, (msg, expected) @@ -1425,22 +1413,3 @@ def test_map_with_map_key(self): ), 'a{content:baz}\n', ) - - -test_cases = [ - SassTestCase, - CompileTestCase, - BuilderTestCase, - ManifestTestCase, - WsgiTestCase, - DistutilsTestCase, - SasscTestCase, - CompileDirectoriesTest, - SassFunctionTest, - SassTypesTest, - CustomFunctionsTest, -] -loader = unittest.defaultTestLoader -suite = unittest.TestSuite() -for test_case in test_cases: - suite.addTests(loader.loadTestsFromTestCase(test_case)) diff --git a/setup.py b/setup.py index 1f83aefa..e3df3f18 100644 --- a/setup.py +++ b/setup.py @@ -141,10 +141,6 @@ def restore_cencode(): ) install_requires = ['six'] -tests_require = [ - 'flake8 >= 2.4.0', - 'Werkzeug >= 0.9' -] def version(sass_filename='sass.py'): @@ -239,10 +235,7 @@ def run(self): ] }, install_requires=install_requires, - tests_require=tests_require, - test_suite='sasstests.suite', extras_require={ - 'tests': tests_require, 'upload_appveyor_builds': [ 'twine == 1.5.0', ], diff --git a/tox.ini b/tox.ini index dd16407b..a16597b2 100644 --- a/tox.ini +++ b/tox.ini @@ -2,10 +2,8 @@ envlist = pypy, pypy3, py26, py27, py33, py34, py35 [testenv] -deps = - flake8 >= 2.4.0 - Werkzeug >= 0.9 +deps = -rrequirements-dev.txt commands = python -c 'from shutil import *; rmtree("build", True)' - python -m unittest sasstests + python -m pytest sasstests.py flake8 .