Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 857f085

Browse files
committed
Loosen up assertion and switch to linematcher.
1 parent dd963d4 commit 857f085

File tree

4 files changed

+51
-68
lines changed

4 files changed

+51
-68
lines changed

‎ci/templates/tox.ini‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ setenv =
1818
passenv =
1919
*
2020
deps =
21+
hunter
22+
mock
23+
nose
24+
process-tests
2125
pytest
22-
pytest-travis-fold
2326
pytest-catchlog
24-
process-tests
25-
nose
26-
mock
27-
tornado
28-
pytest-cov
2927
pytest-clarity
28+
pytest-cov
29+
pytest-travis-fold
30+
tornado<6.0
3031
commands =
3132
{posargs:pytest --cov --cov-report=term-missing -vv --ignore=src}
3233

‎src/aspectlib/utils.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
RegexType = type(re.compile(""))
1313

1414
PY3 = sys.version_info[0] == 3
15+
PY36GT = PY3 and sys.version_info[1] > 6
1516
PY2 = sys.version_info[0] == 2
1617
PY26 = PY2 and sys.version_info[1] == 6
1718
PYPY = platform.python_implementation() == 'PyPy'

‎tests/test_aspectlib_test.py‎

Lines changed: 36 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
from aspectlib.utils import PY26
1717
from aspectlib.utils import repr_ex
1818

19-
format_calls = lambda calls: ''.join(_format_calls(calls))
19+
pytest_plugins = 'pytester',
20+
21+
22+
def format_calls(calls):
23+
return ''.join(_format_calls(calls))
2024

2125

2226
def module_fun(a, b=2):
@@ -278,6 +282,7 @@ def test_xxx():
278282

279283
# TODO
280284

285+
281286
def test_story_text_helpers():
282287
with Story(test_mod) as story:
283288
obj = test_mod.Stuff(1, 2)
@@ -297,19 +302,19 @@ def test_story_text_helpers():
297302
test_mod.func(5)
298303
test_mod.target(1)
299304

300-
print(replay.missing)
305+
print(replay.missing)
301306
assert replay.missing == """stuff_1.meth('b') == 'y' # returns
302307
stuff_2 = test_pkg1.test_pkg2.test_mod.Stuff(2, 3)
303308
stuff_2.meth('c') == 'z' # returns
304309
test_pkg1.test_pkg2.test_mod.target(2) == 3 # returns
305310
"""
306-
print(replay.unexpected)
311+
print(replay.unexpected)
307312
assert replay.unexpected == """stuff_1.meth() == None # returns
308313
stuff_2 = test_pkg1.test_pkg2.test_mod.Stuff(4, 4)
309314
stuff_2.meth() == None # returns
310315
test_pkg1.test_pkg2.test_mod.func(5) == None # returns
311316
"""
312-
print(replay.diff)
317+
print(replay.diff)
313318
if PY26:
314319
assert replay.diff == """--- expected """ """
315320
+++ actual """ """
@@ -344,7 +349,7 @@ def test_story_text_helpers():
344349
"""
345350

346351

347-
def test_story_empty_play_proxy_class_missing_report():
352+
def test_story_empty_play_proxy_class_missing_report(LineMatcher):
348353
with Story(test_mod).replay(recurse_lock=True, proxy=True, strict=False) as replay:
349354
obj = test_mod.Stuff(1, 2)
350355
obj.mix(3, 4)
@@ -362,55 +367,29 @@ def test_story_empty_play_proxy_class_missing_report():
362367
obj.mix()
363368
obj.meth()
364369
obj.mix(10)
365-
366-
print(repr(replay.diff))
367-
368-
if PY26:
369-
assert replay.diff == """--- expected """ """
370-
+++ actual """ """
371-
@@ -1,0 +1,18 @@
372-
+stuff_1 = test_pkg1.test_pkg2.test_mod.Stuff(1, 2)
373-
+stuff_1.mix(3, 4) == (1, 2, 3, 4) # returns
374-
+stuff_1.mix('a', 'b') == (1, 2, 'a', 'b') # returns
375-
+stuff_1.raises(123) ** ValueError((123,),) # raises
376-
+stuff_2 = test_pkg1.test_pkg2.test_mod.Stuff(0, 1)
377-
+stuff_2.mix('a', 'b') == (0, 1, 'a', 'b') # returns
378-
+stuff_2.mix(3, 4) == (0, 1, 3, 4) # returns
379-
+test_pkg1.test_pkg2.test_mod.target() == None # returns
380-
+test_pkg1.test_pkg2.test_mod.raises('badarg') ** ValueError(('badarg',),) # raises
381-
+stuff_2.raises(123) ** ValueError((123,),) # raises
382-
+that_long_stuf_1 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(1)
383-
+that_long_stuf_1.mix(2) == (1, 2) # returns
384-
+that_long_stuf_2 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(3)
385-
+that_long_stuf_2.mix(4) == (3, 4) # returns
386-
+that_long_stuf_3 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(2)
387-
+that_long_stuf_3.mix() == (2,) # returns
388-
+that_long_stuf_3.meth() == None # returns
389-
+that_long_stuf_3.mix(10) == (2, 10) # returns
390-
"""
391-
else:
392-
assert replay.diff == """--- expected
393-
+++ actual
394-
@@ -0,0 +1,18 @@
395-
+stuff_1 = test_pkg1.test_pkg2.test_mod.Stuff(1, 2)
396-
+stuff_1.mix(3, 4) == (1, 2, 3, 4) # returns
397-
+stuff_1.mix('a', 'b') == (1, 2, 'a', 'b') # returns
398-
+stuff_1.raises(123) ** ValueError((123,),) # raises
399-
+stuff_2 = test_pkg1.test_pkg2.test_mod.Stuff(0, 1)
400-
+stuff_2.mix('a', 'b') == (0, 1, 'a', 'b') # returns
401-
+stuff_2.mix(3, 4) == (0, 1, 3, 4) # returns
402-
+test_pkg1.test_pkg2.test_mod.target() == None # returns
403-
+test_pkg1.test_pkg2.test_mod.raises('badarg') ** ValueError(('badarg',),) # raises
404-
+stuff_2.raises(123) ** ValueError((123,),) # raises
405-
+that_long_stuf_1 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(1)
406-
+that_long_stuf_1.mix(2) == (1, 2) # returns
407-
+that_long_stuf_2 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(3)
408-
+that_long_stuf_2.mix(4) == (3, 4) # returns
409-
+that_long_stuf_3 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(2)
410-
+that_long_stuf_3.mix() == (2,) # returns
411-
+that_long_stuf_3.meth() == None # returns
412-
+that_long_stuf_3.mix(10) == (2, 10) # returns
413-
"""
370+
LineMatcher(replay.diff.splitlines()).fnmatch_lines([
371+
"--- expected",
372+
"+++ actual",
373+
"@@ -0,0 +1,18 @@",
374+
"+stuff_1 = test_pkg1.test_pkg2.test_mod.Stuff(1, 2)",
375+
"+stuff_1.mix(3, 4) == (1, 2, 3, 4) # returns",
376+
"+stuff_1.mix('a', 'b') == (1, 2, 'a', 'b') # returns",
377+
"+stuff_1.raises(123) ** ValueError((123,)*) # raises",
378+
"+stuff_2 = test_pkg1.test_pkg2.test_mod.Stuff(0, 1)",
379+
"+stuff_2.mix('a', 'b') == (0, 1, 'a', 'b') # returns",
380+
"+stuff_2.mix(3, 4) == (0, 1, 3, 4) # returns",
381+
"+test_pkg1.test_pkg2.test_mod.target() == None # returns",
382+
"+test_pkg1.test_pkg2.test_mod.raises('badarg') ** ValueError(('badarg',)*) # raises",
383+
"+stuff_2.raises(123) ** ValueError((123,)*) # raises",
384+
"+that_long_stuf_1 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(1)",
385+
"+that_long_stuf_1.mix(2) == (1, 2) # returns",
386+
"+that_long_stuf_2 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(3)",
387+
"+that_long_stuf_2.mix(4) == (3, 4) # returns",
388+
"+that_long_stuf_3 = test_pkg1.test_pkg2.test_mod.ThatLONGStuf(2)",
389+
"+that_long_stuf_3.mix() == (2,) # returns",
390+
"+that_long_stuf_3.meth() == None # returns",
391+
"+that_long_stuf_3.mix(10) == (2, 10) # returns",
392+
])
414393

415394

416395
def test_story_empty_play_proxy_class():
@@ -556,8 +535,8 @@ def test_story_create():
556535
assert isinstance(obj, test_mod.Stuff)
557536
obj.meth('other', 1, 2) == 123
558537
obj.mix('other') == 'mixymix'
559-
#from pprint import pprint as print
560-
#print (dict(story._calls))
538+
#from pprint import pprint as print
539+
#print (dict(story._calls))
561540
assert dict(story._calls) == {
562541
(None, 'test_pkg1.test_pkg2.test_mod.Stuff', "'stuff'", ''): _Binds('stuff_1'),
563542
('stuff_1', 'meth', "'other', 1, 2", ''): _Returns("123"),
@@ -567,6 +546,7 @@ def test_story_create():
567546
(None, 'test_pkg1.test_pkg2.test_mod.target', "'a', 'b', 'c'", ''): _Returns("'abc'"),
568547
}
569548

549+
570550
def xtest_story_empty_play_proxy_class_dependencies():
571551
with Story(test_mod).replay(recurse_lock=True, proxy=True, strict=False) as replay:
572552
obj = test_mod.Stuff(1, 2)

‎tox.ini‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@ setenv =
4343
passenv =
4444
*
4545
deps =
46+
hunter
47+
mock
48+
nose
49+
process-tests
4650
pytest
47-
pytest-travis-fold
4851
pytest-catchlog
49-
process-tests
50-
nose
51-
mock
52-
tornado
53-
pytest-cov
5452
pytest-clarity
53+
pytest-cov
54+
pytest-travis-fold
55+
tornado<6.0
5556
commands =
5657
{posargs:pytest --cov --cov-report=term-missing -vv --ignore=src}
5758

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /