Skip to content

Commit f6e4378

Browse files
committed
Merge pull request #121 from asottile/use_pytest
Use pytest instead of setup.py test
2 parents 30e3a7d + 4beef0f commit f6e4378

File tree

6 files changed

+21
-52
lines changed

6 files changed

+21
-52
lines changed

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ python:
1212
- 3.4
1313
- 3.5
1414
install:
15-
- pip install -e . "flake8 >= 2.4.0" "Werkzeug >= 0.9" coverage coveralls
15+
- pip install -rrequirements-dev.txt coveralls
1616
script:
17-
- coverage run --source sass,sassc,sassutils setup.py test
17+
- coverage run --source sass,sassc,sassutils -m pytest sasstests.py
1818
- flake8 .
1919
after_success:
2020
- coveralls
21+
cache:
22+
directories:
23+
- $HOME/.cache/pip

appveyor.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ init:
2020
- "ECHO %PYTHON%"
2121
- ps: "ls C:/Python*"
2222
install:
23-
- "git -C %APPVEYOR_BUILD_FOLDER% submodule update --init"
23+
- "git submodule update --init"
2424
- "%PYTHON%\\Scripts\\pip.exe --version"
25-
- "%PYTHON%\\Scripts\\pip.exe install wheel"
26-
- "%PYTHON%\\Scripts\\pip.exe install -e ."
25+
- "%PYTHON%\\Scripts\\pip.exe install -rrequirements-dev.txt wheel"
2726
build: false
2827
test_script:
29-
- "%PYTHON%\\python.exe -c \"import os,pprint;pprint.pprint(sorted(os.environ.items()))\""
30-
- "%PYTHON%\\python.exe setup.py test"
28+
- '%PYTHON%\\python.exe -c "import os, pprint; pprint.pprint(sorted(os.environ.items()))"'
29+
- "%PYTHON%\\python.exe -m pytest sasstests.py"
3130
after_test:
3231
- "%PYTHON%\\python.exe setup.py bdist_wheel"
3332
artifacts:
3433
- path: dist\*
34+
cache:
35+
- '%LOCALAPPDATA%\pip\cache'

requirements-dev.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-e .
2+
coverage
3+
flake8>=2.4.0
4+
pytest
5+
werkzeug>=0.9

sasstests.py

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import unittest
1717
import warnings
1818

19+
import pytest
1920
from six import PY3, StringIO, b, string_types, text_type
2021
from werkzeug.test import Client
2122
from werkzeug.wrappers import Response
@@ -230,7 +231,7 @@ def test_compile_disallows_arbitrary_arguments(self):
230231
{'filename': 'test/a.scss'},
231232
{'dirname': ('test', '/dev/null')},
232233
):
233-
with assert_raises(TypeError) as excinfo:
234+
with pytest.raises(TypeError) as excinfo:
234235
sass.compile(herp='derp', harp='darp', **args)
235236
msg, = excinfo.value.args
236237
assert msg == (
@@ -1172,22 +1173,9 @@ def compile_with_func(s):
11721173
return result
11731174

11741175

1175-
@contextlib.contextmanager
1176-
def assert_raises(exctype):
1177-
# I want pytest.raises, this'll have to do for now
1178-
class C:
1179-
pass
1180-
1181-
try:
1182-
yield C
1183-
assert False, 'Expected to raise!'
1184-
except exctype as e:
1185-
C.value = e
1186-
1187-
11881176
@contextlib.contextmanager
11891177
def assert_raises_compile_error(expected):
1190-
with assert_raises(sass.CompileError) as excinfo:
1178+
with pytest.raises(sass.CompileError) as excinfo:
11911179
yield
11921180
msg, = excinfo.value.args
11931181
assert msg.decode('UTF-8') == expected, (msg, expected)
@@ -1425,22 +1413,3 @@ def test_map_with_map_key(self):
14251413
),
14261414
'a{content:baz}\n',
14271415
)
1428-
1429-
1430-
test_cases = [
1431-
SassTestCase,
1432-
CompileTestCase,
1433-
BuilderTestCase,
1434-
ManifestTestCase,
1435-
WsgiTestCase,
1436-
DistutilsTestCase,
1437-
SasscTestCase,
1438-
CompileDirectoriesTest,
1439-
SassFunctionTest,
1440-
SassTypesTest,
1441-
CustomFunctionsTest,
1442-
]
1443-
loader = unittest.defaultTestLoader
1444-
suite = unittest.TestSuite()
1445-
for test_case in test_cases:
1446-
suite.addTests(loader.loadTestsFromTestCase(test_case))

setup.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,6 @@ def restore_cencode():
141141
)
142142

143143
install_requires = ['six']
144-
tests_require = [
145-
'flake8 >= 2.4.0',
146-
'Werkzeug >= 0.9'
147-
]
148144

149145

150146
def version(sass_filename='sass.py'):
@@ -239,10 +235,7 @@ def run(self):
239235
]
240236
},
241237
install_requires=install_requires,
242-
tests_require=tests_require,
243-
test_suite='sasstests.suite',
244238
extras_require={
245-
'tests': tests_require,
246239
'upload_appveyor_builds': [
247240
'twine == 1.5.0',
248241
],

tox.ini

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
envlist = pypy, pypy3, py26, py27, py33, py34, py35
33

44
[testenv]
5-
deps =
6-
flake8 >= 2.4.0
7-
Werkzeug >= 0.9
5+
deps = -rrequirements-dev.txt
86
commands =
97
python -c 'from shutil import *; rmtree("build", True)'
10-
python -m unittest sasstests
8+
python -m pytest sasstests.py
119
flake8 .

0 commit comments

Comments
 (0)