Skip to content

Commit 15c58f6

Browse files
committed
Fixup tests.
1 parent f04bc0c commit 15c58f6

5 files changed

Lines changed: 39 additions & 28 deletions

File tree

tests/sample2.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ def wrapper(*args):
1818
def foo(*args):
1919
return args
2020

21-
foo('aăă', 'b')
21+
foo(
22+
'aăă',
23+
'b',
24+
)
2225
try:
23-
None('a', 'b') # dăh!
26+
None(
27+
'a',
28+
'b',
29+
) # dăh!
2430
except:
2531
pass

tests/test_cookbook.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,14 @@ def no_probe(*args, **kwargs):
6666

6767
@pytest.mark.parametrize('impl', [fast_probe, brief_probe, no_probe])
6868
def test_probe(impl, benchmark):
69-
with impl(
70-
'%s.baz' % __name__,
71-
hunter.VarsPrinter('foo', stream=open(os.devnull, 'w')),
72-
kind='return',
73-
depth=0,
74-
):
75-
benchmark(bar)
69+
with open(os.devnull, 'w') as stream:
70+
with impl(
71+
'%s.baz' % __name__,
72+
hunter.VarsPrinter('foo', stream=stream),
73+
kind='return',
74+
depth=0,
75+
):
76+
benchmark(bar)
7677

7778

7879
class ProfileAction(ColorStreamAction):

tests/test_integration.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_pth_sample2(LineMatcher):
9595
lm.fnmatch_lines(
9696
[
9797
'*tests*sample2.py:* call *',
98-
'*tests*sample2.py:* line if __name__ == "__main__": #*',
98+
"*tests*sample2.py:* line if __name__ == '__main__': #*",
9999
'*tests*sample2.py:* line import functools',
100100
'*tests*sample2.py:* line def deco(opt):',
101101
'*tests*sample2.py:* line @deco(1)',
@@ -133,7 +133,7 @@ def test_pth_sample2(LineMatcher):
133133
'* * ... return value: <function foo *',
134134
'*tests*sample2.py:* line foo(',
135135
"*tests*sample2.py:* line 'a*',",
136-
"*tests*sample2.py:* line 'b'",
136+
"*tests*sample2.py:* line 'b',",
137137
'*tests*sample2.py:* call @functools.wraps(func)',
138138
'* * [*] def wrapper(*args):',
139139
'*tests*sample2.py:* line return func(*args)',
@@ -159,7 +159,7 @@ def test_pth_sample2(LineMatcher):
159159
'*tests*sample2.py:* line try:',
160160
'*tests*sample2.py:* line None(',
161161
"*tests*sample2.py:* line 'a',",
162-
"*tests*sample2.py:* line 'b'",
162+
"*tests*sample2.py:* line 'b',",
163163
'*tests*sample2.py:* exception *',
164164
'* * ... exception value: *',
165165
'*tests*sample2.py:* line except:',
@@ -498,7 +498,7 @@ def a():
498498
'* ... return value: None',
499499
'*---------------------- function exit',
500500
'*>>>>>>>>>>>>>>>>>>>>>> tracing silenced2 on (*RuntimeError*)',
501-
'*test_*.py:* line print("Done silenced1")',
501+
"*test_*.py:* line print('Done silenced1')",
502502
'*test_*.py:* line silenced2()',
503503
'*sample8errors.py:21 call def silenced2():',
504504
'*sample8errors.py:22 line try:',
@@ -520,7 +520,7 @@ def a():
520520
'*sample8errors.py:27 line log(i)',
521521
'*---------------------- too many lines',
522522
'*>>>>>>>>>>>>>>>>>>>>>> tracing silenced3 on (*RuntimeError*)',
523-
'*test_*.py:* line print("Done silenced2")',
523+
"*test_*.py:* line print('Done silenced2')",
524524
'*test_*.py:* line silenced3()',
525525
'*sample8errors.py:31 call def silenced3():',
526526
'*sample8errors.py:32 line try:',
@@ -533,12 +533,12 @@ def a():
533533
'* ... return value: None',
534534
'*sample8errors.py:33 exception error()',
535535
'* ... exception value: (*RuntimeError*)',
536-
'*sample8errors.py:35 line return "mwhahaha"',
537-
'*sample8errors.py:35 return return "mwhahaha"',
536+
"*sample8errors.py:35 line return 'mwhahaha'",
537+
"*sample8errors.py:35 return return 'mwhahaha'",
538538
"* ... return value: 'mwhahaha'",
539539
'*---------------------- function exit',
540540
'*>>>>>>>>>>>>>>>>>>>>>> tracing silenced4 on (*RuntimeError*)',
541-
'*test_*.py:* line print("Done silenced3")',
541+
"*test_*.py:* line print('Done silenced3')",
542542
'*test_*.py:* line silenced4()',
543543
'*sample8errors.py:38 call def silenced4():',
544544
'*sample8errors.py:39 line try:',
@@ -609,8 +609,8 @@ def a():
609609
'*sample8errors.py:27 line log(i)',
610610
'*---------------------- too many lines',
611611
'*>>>>>>>>>>>>>>>>>>>>>> tracing silenced3 on (*RuntimeError*)',
612-
'*sample8errors.py:35 line return "mwhahaha"',
613-
'*sample8errors.py:35 return return "mwhahaha"',
612+
"*sample8errors.py:35 line return 'mwhahaha'",
613+
"*sample8errors.py:35 return return 'mwhahaha'",
614614
"* ... return value: 'mwhahaha'",
615615
'*---------------------- function exit',
616616
'*>>>>>>>>>>>>>>>>>>>>>> tracing silenced4 on (*RuntimeError*)',

tests/test_tracer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ def a():
15621562
'* ... return value: None',
15631563
'*---------------------- function exit',
15641564
'*>>>>>>>>>>>>>>>>>>>>>> tracing silenced2 on (*RuntimeError*)',
1565-
'*test_*.py:* line print("Done silenced1")',
1565+
"*test_*.py:* line print('Done silenced1')",
15661566
'*test_*.py:* line silenced2()',
15671567
'*sample8errors.py:21 call def silenced2():',
15681568
'*sample8errors.py:22 line try:',
@@ -1584,7 +1584,7 @@ def a():
15841584
'*sample8errors.py:27 line log(i)',
15851585
'*---------------------- too many lines',
15861586
'*>>>>>>>>>>>>>>>>>>>>>> tracing silenced3 on (*RuntimeError*)',
1587-
'*test_*.py:* line print("Done silenced2")',
1587+
"*test_*.py:* line print('Done silenced2')",
15881588
'*test_*.py:* line silenced3()',
15891589
'*sample8errors.py:31 call def silenced3():',
15901590
'*sample8errors.py:32 line try:',
@@ -1597,12 +1597,12 @@ def a():
15971597
'* ... return value: None',
15981598
'*sample8errors.py:33 exception error()',
15991599
'* ... exception value: (*RuntimeError*)',
1600-
'*sample8errors.py:35 line return "mwhahaha"',
1601-
'*sample8errors.py:35 return return "mwhahaha"',
1600+
"*sample8errors.py:35 line return 'mwhahaha'",
1601+
"*sample8errors.py:35 return return 'mwhahaha'",
16021602
"* ... return value: 'mwhahaha'",
16031603
'*---------------------- function exit',
16041604
'*>>>>>>>>>>>>>>>>>>>>>> tracing silenced4 on (*RuntimeError*)',
1605-
'*test_*.py:* line print("Done silenced3")',
1605+
"*test_*.py:* line print('Done silenced3')",
16061606
'*test_*.py:* line silenced4()',
16071607
'*sample8errors.py:38 call def silenced4():',
16081608
'*sample8errors.py:39 line try:',
@@ -1673,8 +1673,8 @@ def a():
16731673
'*sample8errors.py:27 line log(i)',
16741674
'*---------------------- too many lines',
16751675
'*>>>>>>>>>>>>>>>>>>>>>> tracing silenced3 on (*RuntimeError*)',
1676-
'*sample8errors.py:35 line return "mwhahaha"',
1677-
'*sample8errors.py:35 return return "mwhahaha"',
1676+
"*sample8errors.py:35 line return 'mwhahaha'",
1677+
"*sample8errors.py:35 return return 'mwhahaha'",
16781678
"* ... return value: 'mwhahaha'",
16791679
'*---------------------- function exit',
16801680
'*>>>>>>>>>>>>>>>>>>>>>> tracing silenced4 on (*RuntimeError*)',

tests/test_util.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,14 @@ def method(self):
8383

8484

8585
def test_safe_repr():
86+
s1 = _socket.socket()
87+
s2 = socket()
8688
data = {
8789
'a': [set('b')],
8890
('c',): deque(['d']),
89-
'e': _socket.socket(),
91+
'e': s1,
9092
1: array('d', [1, 2]),
91-
frozenset('f'): socket(),
93+
frozenset('f'): s2,
9294
'g': Dict(
9395
{
9496
'a': List('123'),
@@ -135,6 +137,8 @@ def test_safe_repr():
135137
print(safe_repr([[[[data]]]]))
136138
print(safe_repr([[[[[data]]]]]))
137139

140+
s1.close()
141+
s2.close()
138142
assert safe_repr(py.io).startswith('<py._vendored_packages.apipkg.ApiModule object at 0x')
139143

140144

0 commit comments

Comments
 (0)