/
usr
/
lib
/
python3
/
dist-packages
/
twisted
/
trial
/
test
/
/usr/lib/python3/dist-packages/twisted/trial/test
mkdir
upload
Name
Size
Mode
Actions
__pycache__/
-
0755
rm
detests.py
5667
0644
edit
dl
rm
erroneous.py
4792
0644
edit
dl
rm
mockcustomsuite.py
536
0644
edit
dl
rm
mockcustomsuite2.py
533
0644
edit
dl
rm
mockcustomsuite3.py
676
0644
edit
dl
rm
mockdoctest.py
2421
0644
edit
dl
rm
moduleself.py
170
0644
edit
dl
rm
moduletest.py
302
0644
edit
dl
rm
novars.py
182
0644
edit
dl
rm
ordertests.py
864
0644
edit
dl
rm
packages.py
4651
0644
edit
dl
rm
sample.py
2084
0644
edit
dl
rm
scripttest.py
457
0755
edit
dl
rm
skipping.py
5709
0644
edit
dl
rm
suppression.py
2499
0644
edit
dl
rm
test_assertions.py
60813
0644
edit
dl
rm
test_asyncassertions.py
2552
0644
edit
dl
rm
test_deferred.py
8822
0644
edit
dl
rm
test_doctest.py
1713
0644
edit
dl
rm
test_keyboard.py
3784
0644
edit
dl
rm
test_loader.py
22360
0644
edit
dl
rm
test_log.py
8040
0644
edit
dl
rm
test_output.py
5016
0644
edit
dl
rm
test_plugins.py
1460
0644
edit
dl
rm
test_pyunitcompat.py
7620
0644
edit
dl
rm
test_reporter.py
56709
0644
edit
dl
rm
test_runner.py
35040
0644
edit
dl
rm
test_script.py
29377
0644
edit
dl
rm
test_skip.py
2651
0644
edit
dl
rm
test_suppression.py
5911
0644
edit
dl
rm
test_testcase.py
1985
0644
edit
dl
rm
test_tests.py
49500
0644
edit
dl
rm
test_util.py
19660
0644
edit
dl
rm
test_warning.py
17638
0644
edit
dl
rm
weird.py
675
0644
edit
dl
rm
__init__.py
130
0644
edit
dl
rm
Edit:
/usr/lib/python3/dist-packages/twisted/trial/test/mockdoctest.py
(2421B)
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. # this module is a trivial class with doctests to test trial's doctest # support. class Counter: """a simple counter object for testing trial's doctest support >>> c = Counter() >>> c.value() 0 >>> c += 3 >>> c.value() 3 >>> c.incr() >>> c.value() == 4 True >>> c == 4 True >>> c != 9 True """ _count = 0 def __init__(self, initialValue=0, maxval=None): self._count = initialValue self.maxval = maxval def __iadd__(self, other): """add other to my value and return self >>> c = Counter(100) >>> c += 333 >>> c == 433 True """ if self.maxval is not None and ((self._count + other) > self.maxval): raise ValueError("sorry, counter got too big") else: self._count += other return self def __eq__(self, other: object) -> bool: """equality operator, compare other to my value() >>> c = Counter() >>> c == 0 True >>> c += 10 >>> c.incr() >>> c == 10 # fail this test on purpose True """ return self._count == other def __ne__(self, other: object) -> bool: """inequality operator >>> c = Counter() >>> c != 10 True """ return not self.__eq__(other) def incr(self): """increment my value by 1 >>> from twisted.trial.test.mockdoctest import Counter >>> c = Counter(10, 11) >>> c.incr() >>> c.value() == 11 True >>> c.incr() Traceback (most recent call last): File "<stdin>", line 1, in ? File "twisted/trial/test/mockdoctest.py", line 51, in incr self.__iadd__(1) File "twisted/trial/test/mockdoctest.py", line 39, in __iadd__ raise ValueError, "sorry, counter got too big" ValueError: sorry, counter got too big """ self.__iadd__(1) def value(self): """return this counter's value >>> c = Counter(555) >>> c.value() == 555 True """ return self._count def unexpectedException(self): """i will raise an unexpected exception... ... *CAUSE THAT'S THE KINDA GUY I AM* >>> 1/0 """
Save
cmd:
run