uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
2dd5b146383e396c5fe095dd
train
class
class TestExtendedToOriginalAddExpectedFailure( TestExtendedToOriginalAddError): outcome = 'addExpectedFailure' def test_outcome_Original_py26(self): self.make_26_result() self.check_outcome_exc_info_to_nothing(self.outcome, 'addSuccess') def test_outcome_Extended_py26(self): ...
class TestExtendedToOriginalAddExpectedFailure( TestExtendedToOriginalAddError):
outcome = 'addExpectedFailure' def test_outcome_Original_py26(self): self.make_26_result() self.check_outcome_exc_info_to_nothing(self.outcome, 'addSuccess') def test_outcome_Extended_py26(self): self.make_26_result() self.check_outcome_details_to_nothing(self.outcome, 'add...
That( lambda: getattr(self.converter, self.outcome)(self), Raises(MatchesException(ValueError))) class TestExtendedToOriginalAddFailure( TestExtendedToOriginalAddError): outcome = 'addFailure' class TestExtendedToOriginalAddExpectedFailure( TestExtendedToOriginalAddError):
64
64
96
17
47
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestExtendedToOriginalAddExpectedFailure
TestExtendedToOriginalAddExpectedFailure
2,353
2,364
2,353
2,355
709768b15472ff9a2f6440678cb8f3e6d07e9684
bigcode/the-stack
train
6dce60b7d94d44d24d13ef54
train
class
class TestPython27TestResultContract(TestCase, Python27Contract): def makeResult(self): return Python27TestResult()
class TestPython27TestResultContract(TestCase, Python27Contract):
def makeResult(self): return Python27TestResult()
26Contract): def makeResult(self): return Python26TestResult() class TestAdaptedPython26TestResultContract(TestCase, FallbackContract): def makeResult(self): return ExtendedToOriginalDecorator(Python26TestResult()) class TestPython27TestResultContract(TestCase, Python27Contract):
64
64
27
14
50
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestPython27TestResultContract
TestPython27TestResultContract
466
469
466
467
ee85ead6c5854c06a31a3bcc6f842b77f96a1da1
bigcode/the-stack
train
8efd327fb3f9447c6dc4b2fd
train
function
def make_erroring_test(): class Test(TestCase): def error(self): a = 1 1/0 return Test("error")
def make_erroring_test():
class Test(TestCase): def error(self): a = 1 1/0 return Test("error")
( Python26TestResult, Python27TestResult, ExtendedTestResult, StreamResult as LoggingStreamResult, TwistedTestResult, ) from testtools.testresult.real import ( _details_to_str, _merge_tags, utc, ) def make_erroring_test():
64
64
35
6
58
zaneb/testtools
testtools/tests/test_testresult.py
Python
make_erroring_test
make_erroring_test
97
102
97
97
49c9b5ad291ae041ca06a9b751cb23d3cc2ade69
bigcode/the-stack
train
548d9e9e83f072eecf7398f7
train
class
class TestThreadSafeForwardingResultContract(TestCase, StartTestRunContract): run_test_with = FullStackRunTest def makeResult(self): result_semaphore = threading.Semaphore(1) target = TestResult() return ThreadsafeForwardingResult(target, result_semaphore)
class TestThreadSafeForwardingResultContract(TestCase, StartTestRunContract):
run_test_with = FullStackRunTest def makeResult(self): result_semaphore = threading.Semaphore(1) target = TestResult() return ThreadsafeForwardingResult(target, result_semaphore)
return MultiTestResult(TestResult(), TestResult()) class TestTextTestResultContract(TestCase, StartTestRunContract): run_test_with = FullStackRunTest def makeResult(self): return TextTestResult(StringIO()) class TestThreadSafeForwardingResultContract(TestCase, StartTestRunContract):
64
64
62
16
48
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestThreadSafeForwardingResultContract
TestThreadSafeForwardingResultContract
438
445
438
439
4751d6cd7d8ab3db78108c076dcf055368548c29
bigcode/the-stack
train
2a8d03ca73e0377d6a1c54a0
train
class
class TestTestResultDecoratorContract(TestCase, StartTestRunContract): run_test_with = FullStackRunTest def makeResult(self): return TestResultDecorator(TestResult())
class TestTestResultDecoratorContract(TestCase, StartTestRunContract):
run_test_with = FullStackRunTest def makeResult(self): return TestResultDecorator(TestResult())
Case, DetailsContract): def makeResult(self): return ExtendedToOriginalDecorator(TwistedTestResult()) class TestAdaptedStreamResult(TestCase, DetailsContract): def makeResult(self): return ExtendedToStreamDecorator(StreamResult()) class TestTestResultDecoratorContract(TestCase, StartTestRunC...
64
64
38
14
50
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestTestResultDecoratorContract
TestTestResultDecoratorContract
490
495
490
491
b25fb6b9088453b4fcae462c5aaecb775634ceb9
bigcode/the-stack
train
bd050d2f9f2dfb7909e2bec8
train
class
class TestControlContract(object): """Stopping test runs.""" def test_initially_not_shouldStop(self): # A result is not set to stop initially. result = self.makeResult() self.assertFalse(result.shouldStop) def test_stop_sets_shouldStop(self): # Calling 'stop()' sets 'should...
class TestControlContract(object):
"""Stopping test runs.""" def test_initially_not_shouldStop(self): # A result is not set to stop initially. result = self.makeResult() self.assertFalse(result.shouldStop) def test_stop_sets_shouldStop(self): # Calling 'stop()' sets 'shouldStop' to True. result = sel...
make_test(): class Test(TestCase): def test(self): pass return Test("test") def make_exception_info(exceptionFactory, *args, **kwargs): try: raise exceptionFactory(*args, **kwargs) except: return sys.exc_info() class TestControlContract(object):
64
64
91
6
58
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestControlContract
TestControlContract
140
152
140
140
57c3ad54d200ff6d4fad7ac07f1b157a8e5abc9a
bigcode/the-stack
train
9ba250776e66469fe4fa4799
train
class
class TestTimestampingStreamResult(TestCase): def test_startTestRun(self): result = TimestampingStreamResult(LoggingStreamResult()) result.startTestRun() self.assertEqual([('startTestRun',)], result.targets[0]._events) def test_stopTestRun(self): result = TimestampingStreamResu...
class TestTimestampingStreamResult(TestCase):
def test_startTestRun(self): result = TimestampingStreamResult(LoggingStreamResult()) result.startTestRun() self.assertEqual([('startTestRun',)], result.targets[0]._events) def test_stopTestRun(self): result = TimestampingStreamResult(LoggingStreamResult()) result.stopTe...
self.assertEqual( [('startTest', test1), ('tags', set(['foo']), set(['bar'])), ('addSuccess', test1), ('stopTest', test1), ('startTest', test2), ('tags', set(['foo']), set(['bar'])), ('addSuccess', test2), ('stopTest...
93
93
313
9
84
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestTimestampingStreamResult
TestTimestampingStreamResult
3,043
3,072
3,043
3,044
dbaa94a1d1e9c898073b2306236365984b55964b
bigcode/the-stack
train
5af761c439404bd3828c72d9
train
class
class TestTextTestResult(TestCase): """Tests for 'TextTestResult'.""" def setUp(self): super(TestTextTestResult, self).setUp() self.result = TextTestResult(StringIO()) def getvalue(self): return self.result.stream.getvalue() def test__init_sets_stream(self): result = T...
class TestTextTestResult(TestCase):
"""Tests for 'TextTestResult'.""" def setUp(self): super(TestTextTestResult, self).setUp() self.result = TextTestResult(StringIO()) def getvalue(self): return self.result.stream.getvalue() def test__init_sets_stream(self): result = TextTestResult("fp") self.ass...
.stopTestRun() self.assertResultLogsEqual([('stopTestRun')]) def test_stopTestRun_returns_results(self): # `MultiTestResult.stopTestRun` returns a tuple of all of the return # values the `stopTestRun`s that it forwards to. class Result(LoggingResult): def stopTestRun(sel...
256
256
1,007
8
248
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestTextTestResult
TestTextTestResult
1,477
1,599
1,477
1,477
0198d0021678ad5d9d3c3774918643d5c46292e1
bigcode/the-stack
train
25f7b111363a574d24fde1cd
train
class
class TestExtendedToOriginalResultOtherAttributes( TestExtendedToOriginalResultDecoratorBase): def test_other_attribute(self): class OtherExtendedResult: def foo(self): return 2 bar = 1 self.result = OtherExtendedResult() self.make_converter() ...
class TestExtendedToOriginalResultOtherAttributes( TestExtendedToOriginalResultDecoratorBase):
def test_other_attribute(self): class OtherExtendedResult: def foo(self): return 2 bar = 1 self.result = OtherExtendedResult() self.make_converter() self.assertEqual(1, self.converter.bar) self.assertEqual(2, self.converter.foo())
self.make_27_result() self.check_outcome_details_to_nothing(self.outcome) def test_outcome_Extended_pyextended(self): self.make_extended_result() self.check_outcome_details(self.outcome) class TestExtendedToOriginalResultOtherAttributes( TestExtendedToOriginalResultDecoratorBase):
64
64
82
18
46
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestExtendedToOriginalResultOtherAttributes
TestExtendedToOriginalResultOtherAttributes
2,475
2,486
2,475
2,477
d5f70b4bcfa12fe088858487c59991967cd65fd0
bigcode/the-stack
train
2f0a83b8f4b0f9e0ee079688
train
class
class TestMultiTestResultContract(TestCase, StartTestRunContract): run_test_with = FullStackRunTest def makeResult(self): return MultiTestResult(TestResult(), TestResult())
class TestMultiTestResultContract(TestCase, StartTestRunContract):
run_test_with = FullStackRunTest def makeResult(self): return MultiTestResult(TestResult(), TestResult())
(self) result.startTestRun() self.assertTrue(result.wasSuccessful()) class TestTestResultContract(TestCase, StartTestRunContract): run_test_with = FullStackRunTest def makeResult(self): return TestResult() class TestMultiTestResultContract(TestCase, StartTestRunContract):
64
64
41
14
50
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestMultiTestResultContract
TestMultiTestResultContract
422
427
422
423
331ceed70d37b8587bdc07fad928d45bd01bc37f
bigcode/the-stack
train
b36533b1fd3c5db92453a2d1
train
class
class TestStreamToExtendedDecoratorContract(TestCase, TestStreamResultContract): def _make_result(self): return StreamToExtendedDecorator(ExtendedTestResult())
class TestStreamToExtendedDecoratorContract(TestCase, TestStreamResultContract):
def _make_result(self): return StreamToExtendedDecorator(ExtendedTestResult())
_result(self): return StreamTagger([StreamResult()], add=set(), discard=set()) class TestStreamToDictContract(TestCase, TestStreamResultContract): def _make_result(self): return StreamToDict(lambda x:None) class TestStreamToExtendedDecoratorContract(TestCase, TestStreamResultContract):
64
64
33
15
49
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestStreamToExtendedDecoratorContract
TestStreamToExtendedDecoratorContract
619
622
619
620
b5ceb68f0f844acc566c7764088b0e294e8511fc
bigcode/the-stack
train
5612b304fe8278521909a698
train
class
class TestStreamFailFastContract(TestCase, TestStreamResultContract): def _make_result(self): return StreamFailFast(lambda:None)
class TestStreamFailFastContract(TestCase, TestStreamResultContract):
def _make_result(self): return StreamFailFast(lambda:None)
_result(self): return StreamToExtendedDecorator(ExtendedTestResult()) class TestStreamToQueueContract(TestCase, TestStreamResultContract): def _make_result(self): queue = Queue() return StreamToQueue(queue, "foo") class TestStreamFailFastContract(TestCase, TestStreamResultContract):
64
64
30
14
50
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestStreamFailFastContract
TestStreamFailFastContract
632
635
632
633
482daeea7953dfe03f5494af285697a1b6efe23a
bigcode/the-stack
train
a0ede35acaa58960d2e74586
train
class
class TestExtendedToOriginalAddSuccess( TestExtendedToOriginalResultDecoratorBase): outcome = 'addSuccess' expected = 'addSuccess' def test_outcome_Original_py26(self): self.make_26_result() self.check_outcome_nothing(self.outcome, self.expected) def test_outcome_Original_py27(sel...
class TestExtendedToOriginalAddSuccess( TestExtendedToOriginalResultDecoratorBase):
outcome = 'addSuccess' expected = 'addSuccess' def test_outcome_Original_py26(self): self.make_26_result() self.check_outcome_nothing(self.outcome, self.expected) def test_outcome_Original_py27(self): self.make_27_result() self.check_outcome_nothing(self.outcome) d...
(self.outcome) def test_outcome__no_details(self): self.make_extended_result() self.assertThat( lambda: getattr(self.converter, self.outcome)(self), Raises(MatchesException(ValueError))) class TestExtendedToOriginalAddSuccess( TestExtendedToOriginalResultDecoratorBase): ...
63
64
212
17
46
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestExtendedToOriginalAddSuccess
TestExtendedToOriginalAddSuccess
2,409
2,437
2,409
2,411
5e6ed342c53217d9acabf99e2be4d76e8dc6f24b
bigcode/the-stack
train
e26f588045d1ef9cd4155513
train
class
class TestCopyStreamResultContract(TestCase, TestStreamResultContract): def _make_result(self): return CopyStreamResult([StreamResult(), StreamResult()])
class TestCopyStreamResultContract(TestCase, TestStreamResultContract):
def _make_result(self): return CopyStreamResult([StreamResult(), StreamResult()])
for ss in chain.from_iterable(combos): param_dicts.append(dict(ss)) return param_dicts class TestBaseStreamResultContract(TestCase, TestStreamResultContract): def _make_result(self): return StreamResult() class TestCopyStreamResultContract(TestCase, TestStreamResultContract):
64
64
33
14
50
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestCopyStreamResultContract
TestCopyStreamResultContract
577
580
577
578
1bec55d733f6a5eb2d275890477a94a35bc2130d
bigcode/the-stack
train
5efdad6994aa17847e18cba6
train
class
class TestStreamTagger(TestCase): def test_adding(self): log = LoggingStreamResult() result = StreamTagger([log], add=['foo']) result.startTestRun() result.status() result.status(test_tags=set(['bar'])) result.status(test_tags=None) result.stopTestRun() ...
class TestStreamTagger(TestCase):
def test_adding(self): log = LoggingStreamResult() result = StreamTagger([log], add=['foo']) result.startTestRun() result.status() result.status(test_tags=set(['bar'])) result.status(test_tags=None) result.stopTestRun() self.assertEqual([ (...
.now(utc) self.result.status("foo", "success", test_tags=set(['tag']), runnable=False, file_name="foo", file_bytes=b'bar', eof=True, mime_type="text/json", route_code='abc', timestamp=now) self.assertThat(self.targets, AllMatch(Equals([('startTestRun',), ...
119
120
403
8
111
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestStreamTagger
TestStreamTagger
712
748
712
713
32fc8e67e9f65212a3dfa274b2910536b2f93edb
bigcode/the-stack
train
243d3045a80914ad20148572
train
class
class TestStreamToQueue(TestCase): def make_result(self): queue = Queue() return queue, StreamToQueue(queue, "foo") def test_status(self): def check_event(event_dict, route=None, time=None): self.assertEqual("status", event_dict['event']) self.assertEqual("test"...
class TestStreamToQueue(TestCase):
def make_result(self): queue = Queue() return queue, StreamToQueue(queue, "foo") def test_status(self): def check_event(event_dict, route=None, time=None): self.assertEqual("status", event_dict['event']) self.assertEqual("test", event_dict['test_id']) ...
_start_stop_run=True) router.startTestRun() router.stopTestRun() self.assertEqual([ ('startTestRun',), ('stopTestRun',), ], nontest._events) def test_add_rule_do_start_stop_run_after_startTestRun(self): nontest = LoggingStreamResult() rout...
144
144
480
8
136
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestStreamToQueue
TestStreamToQueue
2,024
2,069
2,024
2,025
ce47b9eb7ad263b84d2a8e9d21a9c859b16621b4
bigcode/the-stack
train
720597bd57eae7a6041b5bb4
train
class
class TestStreamSummaryResultContract(TestCase, TestStreamResultContract): def _make_result(self): return StreamSummary()
class TestStreamSummaryResultContract(TestCase, TestStreamResultContract):
def _make_result(self): return StreamSummary()
): def _make_result(self): return ExtendedToStreamDecorator(StreamResult()) class TestResourcedToStreamDecoratorContract(TestCase, TestStreamResultContract): def _make_result(self): return ResourcedToStreamDecorator(StreamResult()) class TestStreamSummaryResultContract(TestCase, TestStreamRe...
64
64
26
14
50
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestStreamSummaryResultContract
TestStreamSummaryResultContract
601
604
601
602
7f20c561ba3ef7e13b18ce4816be6b73fb660578
bigcode/the-stack
train
b06c54ccdf083dfb644e74fb
train
class
class TestAdaptedTwistedTestResultContract(TestCase, DetailsContract): def makeResult(self): return ExtendedToOriginalDecorator(TwistedTestResult())
class TestAdaptedTwistedTestResultContract(TestCase, DetailsContract):
def makeResult(self): return ExtendedToOriginalDecorator(TwistedTestResult())
27Contract): def makeResult(self): return Python27TestResult() class TestAdaptedPython27TestResultContract(TestCase, DetailsContract): def makeResult(self): return ExtendedToOriginalDecorator(Python27TestResult()) class TestAdaptedTwistedTestResultContract(TestCase, DetailsContract):
64
64
33
15
49
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestAdaptedTwistedTestResultContract
TestAdaptedTwistedTestResultContract
478
481
478
479
bcd31188c6f24fa46713102bcb5f65b08a782b3a
bigcode/the-stack
train
972e6502ac67cc1bddbb06a8
train
class
class TestExtendedToOriginalResultDecoratorBase(TestCase): def make_26_result(self): self.result = Python26TestResult() self.make_converter() def make_27_result(self): self.result = Python27TestResult() self.make_converter() def make_converter(self): self.converter...
class TestExtendedToOriginalResultDecoratorBase(TestCase):
def make_26_result(self): self.result = Python26TestResult() self.make_converter() def make_27_result(self): self.result = Python27TestResult() self.make_converter() def make_converter(self): self.converter = ExtendedToOriginalDecorator(self.result) def make_ex...
_name="file", file_bytes=_b("content"), eof=True, mime_type="quux", route_code=None, timestamp=None) self.assertEqual(1, queue.qsize()) a_time = datetime.datetime.now(utc) result.status("test", "fail", test_tags=set(["quux"]), runnable=False, file_name="file", file_bytes=...
256
256
1,082
11
245
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestExtendedToOriginalResultDecoratorBase
TestExtendedToOriginalResultDecoratorBase
2,072
2,187
2,072
2,073
b1f7fe374b8728d1e7f8002680bd57ff525537ed
bigcode/the-stack
train
027b0454cdfdabc23567e7bb
train
class
class TestStreamToDict(TestCase): def test_hung_test(self): tests = [] result = StreamToDict(tests.append) result.startTestRun() result.status('foo', 'inprogress') self.assertEqual([], tests) result.stopTestRun() self.assertEqual([ {'id': 'foo', '...
class TestStreamToDict(TestCase):
def test_hung_test(self): tests = [] result = StreamToDict(tests.append) result.startTestRun() result.status('foo', 'inprogress') self.assertEqual([], tests) result.stopTestRun() self.assertEqual([ {'id': 'foo', 'tags': set(), 'details': {}, 'statu...
, None, None), ('stopTestRun',), ], log._events) def test_discarding(self): log = LoggingStreamResult() result = StreamTagger([log], discard=['foo']) result.startTestRun() result.status() result.status(test_tags=None) result.status(test_tags=s...
256
256
873
8
248
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestStreamToDict
TestStreamToDict
751
846
751
752
8bc57b104164d79416fa3838fbd9b598abad2285
bigcode/the-stack
train
88e064113be67e737f196552
train
class
class TestExtendedToOriginalAddSkip( TestExtendedToOriginalResultDecoratorBase): outcome = 'addSkip' def test_outcome_Original_py26(self): self.make_26_result() self.check_outcome_string_nothing(self.outcome, 'addSuccess') def test_outcome_Original_py27(self): self.make_27_res...
class TestExtendedToOriginalAddSkip( TestExtendedToOriginalResultDecoratorBase):
outcome = 'addSkip' def test_outcome_Original_py26(self): self.make_26_result() self.check_outcome_string_nothing(self.outcome, 'addSuccess') def test_outcome_Original_py27(self): self.make_27_result() self.check_outcome_string(self.outcome) def test_outcome_Original_p...
' def test_outcome_Original_py26(self): self.make_26_result() self.check_outcome_exc_info_to_nothing(self.outcome, 'addSuccess') def test_outcome_Extended_py26(self): self.make_26_result() self.check_outcome_details_to_nothing(self.outcome, 'addSuccess') class TestExtendedToOri...
89
90
301
17
72
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestExtendedToOriginalAddSkip
TestExtendedToOriginalAddSkip
2,368
2,406
2,368
2,370
61f0d32391bac2d57344d4037a2228025cea8226
bigcode/the-stack
train
7fa7a30f11ecc7661aa6bdb9
train
class
class StartTestRunContract(FallbackContract): """Defines the contract for testtools policy choices. That is things which are not simply extensions to unittest but choices we have made differently. """ def test_startTestRun_resets_unexpected_success(self): result = self.makeResult() ...
class StartTestRunContract(FallbackContract):
"""Defines the contract for testtools policy choices. That is things which are not simply extensions to unittest but choices we have made differently. """ def test_startTestRun_resets_unexpected_success(self): result = self.makeResult() result.startTest(self) result.addUnex...
_addUnexpectedSuccess_was_successful(self): # addUnexpectedSuccess fails test run in testtools. result = self.makeResult() result.startTest(self) result.addUnexpectedSuccess(self) result.stopTest(self) self.assertFalse(result.wasSuccessful()) class StartTestRunContract(Fa...
64
64
203
9
55
zaneb/testtools
testtools/tests/test_testresult.py
Python
StartTestRunContract
StartTestRunContract
382
411
382
382
c4316253aab3dd7f121372036625444680da2290
bigcode/the-stack
train
4d176ab7e4f7f29d8429725a
train
class
class TestResourcedToStreamDecoratorContract(TestCase, TestStreamResultContract): def _make_result(self): return ResourcedToStreamDecorator(StreamResult())
class TestResourcedToStreamDecoratorContract(TestCase, TestStreamResultContract):
def _make_result(self): return ResourcedToStreamDecorator(StreamResult())
StreamResultContract): def _make_result(self): return LoggingStreamResult() class TestExtendedToStreamDecoratorContract(TestCase, TestStreamResultContract): def _make_result(self): return ExtendedToStreamDecorator(StreamResult()) class TestResourcedToStreamDecoratorContract(TestCase, TestStr...
64
64
33
16
48
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestResourcedToStreamDecoratorContract
TestResourcedToStreamDecoratorContract
595
598
595
596
95922a32a7b49807c4268e2ee83d03a308ab7e3f
bigcode/the-stack
train
37e06b76c58fb70f1a49b1f2
train
class
class TestByTestResultTests(TestCase): def setUp(self): super(TestByTestResultTests, self).setUp() self.log = [] self.result = TestByTestResult(self.on_test) now = iter(range(5)) self.result._now = lambda: advance_iterator(now) def assertCalled(self, **kwargs): ...
class TestByTestResultTests(TestCase):
def setUp(self): super(TestByTestResultTests, self).setUp() self.log = [] self.result = TestByTestResult(self.on_test) now = iter(range(5)) self.result._now = lambda: advance_iterator(now) def assertCalled(self, **kwargs): defaults = { 'test': self, ...
' 'attachment-1: {{{\n' 'bar\n' 'bar\n' '}}}\n')) def test_empty_attachment(self): string = _details_to_str({'attachment': text_content('')}) self.assertThat( string, Equals("""\ ...
255
256
1,105
9
246
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestByTestResultTests
TestByTestResultTests
2,860
3,016
2,860
2,861
5916f54e3e5eaabba9316ed5ead0a0fe0b5877fd
bigcode/the-stack
train
32e87be59e6384c062cfc443
train
class
class TestExtendedToOriginalAddUnexpectedSuccess( TestExtendedToOriginalResultDecoratorBase): outcome = 'addUnexpectedSuccess' expected = 'addFailure' def test_outcome_Original_py26(self): self.make_26_result() getattr(self.converter, self.outcome)(self) [event] = self.result._...
class TestExtendedToOriginalAddUnexpectedSuccess( TestExtendedToOriginalResultDecoratorBase):
outcome = 'addUnexpectedSuccess' expected = 'addFailure' def test_outcome_Original_py26(self): self.make_26_result() getattr(self.converter, self.outcome)(self) [event] = self.result._events self.assertEqual((self.expected, self), event[:2]) def test_outcome_Original_py...
def test_outcome_Extended_py27(self): self.make_27_result() self.check_outcome_details_to_nothing(self.outcome) def test_outcome_Extended_pyextended(self): self.make_extended_result() self.check_outcome_details(self.outcome) class TestExtendedToOriginalAddUnexpectedSuccess( ...
76
76
254
18
58
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestExtendedToOriginalAddUnexpectedSuccess
TestExtendedToOriginalAddUnexpectedSuccess
2,440
2,472
2,440
2,442
3404f265e53ea5dc7f24af2a765664526bbae8f4
bigcode/the-stack
train
23b9d33be9a2d19cd177a90a
train
class
class TestStreamResultRouter(TestCase): def test_start_stop_test_run_no_fallback(self): result = StreamResultRouter() result.startTestRun() result.stopTestRun() def test_no_fallback_errors(self): self.assertRaises(Exception, StreamResultRouter().status, test_id='f') def te...
class TestStreamResultRouter(TestCase):
def test_start_stop_test_run_no_fallback(self): result = StreamResultRouter() result.startTestRun() result.stopTestRun() def test_no_fallback_errors(self): self.assertRaises(Exception, StreamResultRouter().status, test_id='f') def test_fallback_calls(self): fallback...
new" # tags, then it overrides the "new" tag, leaving it marked as "gone". current_tags = set(['present', 'going']), set(['missing']) changing_tags = set(), set(['going']) expected = set(['present']), set(['missing', 'going']) self.assertEqual( expected, _merge_tags(c...
256
256
1,191
8
248
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestStreamResultRouter
TestStreamResultRouter
1,885
2,021
1,885
1,886
565e57d46a58c967a192d2f70659ffafba838d18
bigcode/the-stack
train
65cb50c333416b371f640500
train
class
class TestStreamToQueueContract(TestCase, TestStreamResultContract): def _make_result(self): queue = Queue() return StreamToQueue(queue, "foo")
class TestStreamToQueueContract(TestCase, TestStreamResultContract):
def _make_result(self): queue = Queue() return StreamToQueue(queue, "foo")
def _make_result(self): return StreamToDict(lambda x:None) class TestStreamToExtendedDecoratorContract(TestCase, TestStreamResultContract): def _make_result(self): return StreamToExtendedDecorator(ExtendedTestResult()) class TestStreamToQueueContract(TestCase, TestStreamResultContract):
64
64
36
14
50
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestStreamToQueueContract
TestStreamToQueueContract
625
629
625
626
6e7c9b85c37b102b3aafbcf8fad89eb2dd0b733c
bigcode/the-stack
train
f3a892e8ce8448e45ba83052
train
function
def make_exception_info(exceptionFactory, *args, **kwargs): try: raise exceptionFactory(*args, **kwargs) except: return sys.exc_info()
def make_exception_info(exceptionFactory, *args, **kwargs):
try: raise exceptionFactory(*args, **kwargs) except: return sys.exc_info()
Test(TestCase): def succeeded(self): self.expectFailure("yo!", lambda: None) return Test("succeeded") def make_test(): class Test(TestCase): def test(self): pass return Test("test") def make_exception_info(exceptionFactory, *args, **kwargs):
64
64
35
13
51
zaneb/testtools
testtools/tests/test_testresult.py
Python
make_exception_info
make_exception_info
133
137
133
133
e7fac4dd29640cc22a4c7b56430e547885fb50e0
bigcode/the-stack
train
c74a95cbab34c91362647c30
train
class
class TestExtendedToStreamDecorator(TestCase): def test_explicit_time(self): log = LoggingStreamResult() result = ExtendedToStreamDecorator(log) result.startTestRun() now = datetime.datetime.now(utc) result.time(now) result.startTest(self) result.addSuccess(s...
class TestExtendedToStreamDecorator(TestCase):
def test_explicit_time(self): log = LoggingStreamResult() result = ExtendedToStreamDecorator(log) result.startTestRun() now = datetime.datetime.now(utc) result.time(now) result.startTest(self) result.addSuccess(self) result.stopTest(self) resul...
result.stopTestRun() self.assertThat(tests, HasLength(2)) self.assertEqual(["A", "B"], tests[0]['timestamps']) self.assertEqual(["C", None], tests[1]['timestamps']) def test_files_skipped(self): tests = [] result = StreamToDict(tests.append) result.startTestRun() ...
158
158
529
9
149
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestExtendedToStreamDecorator
TestExtendedToStreamDecorator
849
940
849
850
00f168c740d3dbbaef06b5c4347cd53d4b3537eb
bigcode/the-stack
train
9663ff9b4f596f4886785d67
train
class
class TestStreamFailFast(TestCase): def test_inprogress(self): result = StreamFailFast(self.fail) result.status('foo', 'inprogress') def test_exists(self): result = StreamFailFast(self.fail) result.status('foo', 'exists') def test_xfail(self): result = StreamFailFa...
class TestStreamFailFast(TestCase):
def test_inprogress(self): result = StreamFailFast(self.fail) result.status('foo', 'inprogress') def test_exists(self): result = StreamFailFast(self.fail) result.status('foo', 'exists') def test_xfail(self): result = StreamFailFast(self.fail) result.status('...
ResourcedToStreamDecorator(log) resource = testresources.TestResourceManager() result.startTestRun() result.stopCleanResource(resource) [_, event] = log._events self.assertEqual( 'testresources.TestResourceManager.clean', event.test_id) self.assertEqual('succ...
76
76
254
8
68
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestStreamFailFast
TestStreamFailFast
1,008
1,046
1,008
1,009
158e7f54dc2994b2a8e49da6f599ddccc7001e99
bigcode/the-stack
train
2ecc1faf9d12336b149261dd
train
class
class TestTagger(TestCase): def test_tags_tests(self): result = ExtendedTestResult() tagger = Tagger(result, set(['foo']), set(['bar'])) test1, test2 = self, make_test() tagger.startTest(test1) tagger.addSuccess(test1) tagger.stopTest(test1) tagger.startTest(...
class TestTagger(TestCase):
def test_tags_tests(self): result = ExtendedTestResult() tagger = Tagger(result, set(['foo']), set(['bar'])) test1, test2 = self, make_test() tagger.startTest(test1) tagger.addSuccess(test1) tagger.stopTest(test1) tagger.startTest(test2) tagger.addSucc...
'details': {'foo': 'bar'}}, {'test': self, 'status': 'success', 'start_time': 2, 'stop_time': 3, 'tags': set(), 'details': None}, ], self.log) class TestTagger(TestCase):
64
64
182
7
57
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestTagger
TestTagger
3,019
3,040
3,019
3,020
85db8257625cceefd638312e3738e38616ea3a6b
bigcode/the-stack
train
224b3dc5edcf6e7a5fe7e34c
train
class
class TestNonAsciiResults(TestCase): """Test all kinds of tracebacks are cleanly interpreted as unicode Currently only uses weak "contains" assertions, would be good to be much stricter about the expected output. This would add a few failures for the current release of IronPython for instance, which ge...
class TestNonAsciiResults(TestCase):
"""Test all kinds of tracebacks are cleanly interpreted as unicode Currently only uses weak "contains" assertions, would be good to be much stricter about the expected output. This would add a few failures for the current release of IronPython for instance, which gets some traceback lines muddled. ...
test_outcome_Original_py27(self): self.make_27_result() self.check_outcome_nothing(self.outcome) def test_outcome_Original_pyextended(self): self.make_extended_result() self.check_outcome_nothing(self.outcome) def test_outcome_Extended_py26(self): self.make_26_result()...
256
256
2,770
8
248
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestNonAsciiResults
TestNonAsciiResults
2,489
2,763
2,489
2,489
60ad98e2144255e80e20626bb22c0228ce38f6ad
bigcode/the-stack
train
eced1c465edd683dc5fb55e7
train
class
class TestAdaptedPython27TestResultContract(TestCase, DetailsContract): def makeResult(self): return ExtendedToOriginalDecorator(Python27TestResult())
class TestAdaptedPython27TestResultContract(TestCase, DetailsContract):
def makeResult(self): return ExtendedToOriginalDecorator(Python27TestResult())
FallbackContract): def makeResult(self): return ExtendedToOriginalDecorator(Python26TestResult()) class TestPython27TestResultContract(TestCase, Python27Contract): def makeResult(self): return Python27TestResult() class TestAdaptedPython27TestResultContract(TestCase, DetailsContract):
64
64
33
15
49
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestAdaptedPython27TestResultContract
TestAdaptedPython27TestResultContract
472
475
472
473
d83d1c6e77ab94c0c07e8742c8d82afcfaa63114
bigcode/the-stack
train
6ecbe08c3daf5c6683aac697
train
class
class TagsContract(Python27Contract): """Tests to ensure correct tagging behaviour. See the subunit docs for guidelines on how this is supposed to work. """ def test_no_tags_by_default(self): # Results initially have no tags. result = self.makeResult() result.startTestRun() ...
class TagsContract(Python27Contract):
"""Tests to ensure correct tagging behaviour. See the subunit docs for guidelines on how this is supposed to work. """ def test_no_tags_by_default(self): # Results initially have no tags. result = self.makeResult() result.startTestRun() self.assertEqual(frozenset(), res...
does not fail the test run in Python 2.7. result = self.makeResult() result.startTest(self) result.addUnexpectedSuccess(self) result.stopTest(self) self.assertTrue(result.wasSuccessful()) def test_startStopTestRun(self): # Calling startTestRun completes ok. ...
175
175
585
8
167
zaneb/testtools
testtools/tests/test_testresult.py
Python
TagsContract
TagsContract
249
324
249
249
dcb017bb2afa063b9dffe2b631dc91c5192b77c9
bigcode/the-stack
train
bda8f4869b88054303e578ac
train
class
class TestMultiTestResult(TestCase): """Tests for 'MultiTestResult'.""" def setUp(self): super(TestMultiTestResult, self).setUp() self.result1 = LoggingResult([]) self.result2 = LoggingResult([]) self.multiResult = MultiTestResult(self.result1, self.result2) def assertResul...
class TestMultiTestResult(TestCase):
"""Tests for 'MultiTestResult'.""" def setUp(self): super(TestMultiTestResult, self).setUp() self.result1 = LoggingResult([]) self.result2 = LoggingResult([]) self.multiResult = MultiTestResult(self.result1, self.result2) def assertResultLogsEqual(self, expectedEvents): ...
result.tb_locals = True test = make_erroring_test() test.run(result) self.assertThat( result.errors[0][1], DocTestMatches( 'Traceback (most recent call last):\n' ' File "...testtools...runtest.py", line ..., in _run_user\n' ...
256
256
1,181
8
248
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestMultiTestResult
TestMultiTestResult
1,345
1,474
1,345
1,345
c29d97f5812fa32a5c0e71639a1c115059ce6868
bigcode/the-stack
train
543cf20424c3cffce11c68c1
train
function
def test_suite(): from unittest import TestLoader return TestLoader().loadTestsFromName(__name__)
def test_suite():
from unittest import TestLoader return TestLoader().loadTestsFromName(__name__)
10]) self.assertIsInstance(events[0][10], datetime.datetime) def test_status_timestamp(self): result = TimestampingStreamResult(LoggingStreamResult()) result.status(timestamp="F") self.assertEqual("F", result.targets[0]._events[0][10]) def test_suite():
64
64
23
4
60
zaneb/testtools
testtools/tests/test_testresult.py
Python
test_suite
test_suite
3,075
3,077
3,075
3,075
5fb0e85ba6ee3d72355f21ba5c1a366f346914fb
bigcode/the-stack
train
96bd549c66ca197e7316ee7f
train
class
class TestPython26TestResultContract(TestCase, Python26Contract): def makeResult(self): return Python26TestResult()
class TestPython26TestResultContract(TestCase, Python26Contract):
def makeResult(self): return Python26TestResult()
.Semaphore(1) target = TestResult() return ThreadsafeForwardingResult(target, result_semaphore) class TestExtendedTestResultContract(TestCase, StartTestRunContract): def makeResult(self): return ExtendedTestResult() class TestPython26TestResultContract(TestCase, Python26Contract):
64
64
27
14
50
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestPython26TestResultContract
TestPython26TestResultContract
454
457
454
455
2a3d3cec766c63afbe5759bd2aae7a8278f10507
bigcode/the-stack
train
441ca28b110b9fbdff891047
train
class
class TestDoubleStreamResultEvents(TestCase): def test_startTestRun(self): result = LoggingStreamResult() result.startTestRun() self.assertEqual([('startTestRun',)], result._events) def test_stopTestRun(self): result = LoggingStreamResult() result.startTestRun() ...
class TestDoubleStreamResultEvents(TestCase):
def test_startTestRun(self): result = LoggingStreamResult() result.startTestRun() self.assertEqual([('startTestRun',)], result._events) def test_stopTestRun(self): result = LoggingStreamResult() result.startTestRun() result.stopTestRun() self.assertEqual(...
Contract): def _make_result(self): queue = Queue() return StreamToQueue(queue, "foo") class TestStreamFailFastContract(TestCase, TestStreamResultContract): def _make_result(self): return StreamFailFast(lambda:None) class TestStreamResultRouterContract(TestCase, TestStreamResultCont...
92
92
307
9
83
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestDoubleStreamResultEvents
TestDoubleStreamResultEvents
644
677
644
645
0826719f2bd17b48b8f25a994831200f83477236
bigcode/the-stack
train
b54aef5118516a89f556e5c8
train
class
class FallbackContract(DetailsContract): """When we fallback we take our policy choice to map calls. For instance, we map unexpectedSuccess to an error code, not to success. """ def test_addUnexpectedSuccess_was_successful(self): # addUnexpectedSuccess fails test run in testtools. resu...
class FallbackContract(DetailsContract):
"""When we fallback we take our policy choice to map calls. For instance, we map unexpectedSuccess to an error code, not to success. """ def test_addUnexpectedSuccess_was_successful(self): # addUnexpectedSuccess fails test run in testtools. result = self.makeResult() result.sta...
result.startTest(self) result.addUnexpectedSuccess(self, details={}) def test_addSuccess_details(self): # Calling addSuccess(test) completes ok. result = self.makeResult() result.startTest(self) result.addSuccess(self, details={}) class FallbackContract(DetailsContra...
64
64
99
8
56
zaneb/testtools
testtools/tests/test_testresult.py
Python
FallbackContract
FallbackContract
367
379
367
367
b37e09bcc5069f8ea70da959ffa98d8d43b8c5c4
bigcode/the-stack
train
83911067bcf28d3b9f3cbae7
train
class
class TestExtendedTestResultContract(TestCase, StartTestRunContract): def makeResult(self): return ExtendedTestResult()
class TestExtendedTestResultContract(TestCase, StartTestRunContract):
def makeResult(self): return ExtendedTestResult()
TestRunContract): run_test_with = FullStackRunTest def makeResult(self): result_semaphore = threading.Semaphore(1) target = TestResult() return ThreadsafeForwardingResult(target, result_semaphore) class TestExtendedTestResultContract(TestCase, StartTestRunContract):
64
64
26
14
50
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestExtendedTestResultContract
TestExtendedTestResultContract
448
451
448
449
7623a56914baac0263948e902523cc83686162b5
bigcode/the-stack
train
e159bad6162d8db08e39274e
train
function
def make_unexpectedly_successful_test(): class Test(TestCase): def succeeded(self): self.expectFailure("yo!", lambda: None) return Test("succeeded")
def make_unexpectedly_successful_test():
class Test(TestCase): def succeeded(self): self.expectFailure("yo!", lambda: None) return Test("succeeded")
(TestCase): def failed(self): self.fail("yo!") return Test("failed") def make_mismatching_test(): class Test(TestCase): def mismatch(self): self.assertEqual(1, 2) return Test("mismatch") def make_unexpectedly_successful_test():
64
64
38
9
55
zaneb/testtools
testtools/tests/test_testresult.py
Python
make_unexpectedly_successful_test
make_unexpectedly_successful_test
119
123
119
119
da5c9d9014c5c1cc5ca17ee5d47d61d068486ef2
bigcode/the-stack
train
577065196d71c3bc6c6fc796
train
class
class TestStreamResultContract(object): def _make_result(self): raise NotImplementedError(self._make_result) def test_startTestRun(self): result = self._make_result() result.startTestRun() result.stopTestRun() def test_files(self): # Test parameter combinations whe...
class TestStreamResultContract(object):
def _make_result(self): raise NotImplementedError(self._make_result) def test_startTestRun(self): result = self._make_result() result.startTestRun() result.stopTestRun() def test_files(self): # Test parameter combinations when files are being emitted. result...
, DetailsContract): def makeResult(self): return ExtendedToOriginalDecorator(TwistedTestResult()) class TestAdaptedStreamResult(TestCase, DetailsContract): def makeResult(self): return ExtendedToStreamDecorator(StreamResult()) class TestTestResultDecoratorContract(TestCase, StartTestRunCon...
146
147
491
7
139
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestStreamResultContract
TestStreamResultContract
507
568
507
508
7dd60623769bbfc303e63a060441b3facb1d1d51
bigcode/the-stack
train
93761ec059036787a5db68b9
train
class
class TestExtendedToStreamDecoratorContract(TestCase, TestStreamResultContract): def _make_result(self): return ExtendedToStreamDecorator(StreamResult())
class TestExtendedToStreamDecoratorContract(TestCase, TestStreamResultContract):
def _make_result(self): return ExtendedToStreamDecorator(StreamResult())
Contract): def _make_result(self): return CopyStreamResult([StreamResult(), StreamResult()]) class TestDoubleStreamResultContract(TestCase, TestStreamResultContract): def _make_result(self): return LoggingStreamResult() class TestExtendedToStreamDecoratorContract(TestCase, TestStreamResultCo...
64
64
31
15
49
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestExtendedToStreamDecoratorContract
TestExtendedToStreamDecoratorContract
589
592
589
590
df3223940e27176bd535d8a46009f53b122abcc9
bigcode/the-stack
train
04e74e92c310340c8ecf7bea
train
class
class TestAdaptedStreamResult(TestCase, DetailsContract): def makeResult(self): return ExtendedToStreamDecorator(StreamResult())
class TestAdaptedStreamResult(TestCase, DetailsContract):
def makeResult(self): return ExtendedToStreamDecorator(StreamResult())
): def makeResult(self): return ExtendedToOriginalDecorator(Python27TestResult()) class TestAdaptedTwistedTestResultContract(TestCase, DetailsContract): def makeResult(self): return ExtendedToOriginalDecorator(TwistedTestResult()) class TestAdaptedStreamResult(TestCase, DetailsContract):
64
64
27
12
52
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestAdaptedStreamResult
TestAdaptedStreamResult
484
487
484
485
93d253e1c21220748008de523c049031790dc197
bigcode/the-stack
train
f5846cbf39850fee53119e5f
train
class
class TestStreamResultRouterContract(TestCase, TestStreamResultContract): def _make_result(self): return StreamResultRouter(StreamResult())
class TestStreamResultRouterContract(TestCase, TestStreamResultContract):
def _make_result(self): return StreamResultRouter(StreamResult())
_make_result(self): queue = Queue() return StreamToQueue(queue, "foo") class TestStreamFailFastContract(TestCase, TestStreamResultContract): def _make_result(self): return StreamFailFast(lambda:None) class TestStreamResultRouterContract(TestCase, TestStreamResultContract):
64
64
29
14
50
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestStreamResultRouterContract
TestStreamResultRouterContract
638
641
638
639
200dcc46259c7da45926b21aa5b3b11802d36165
bigcode/the-stack
train
0998ade97df5484a6966655f
train
class
class TestExtendedToOriginalResultDecorator( TestExtendedToOriginalResultDecoratorBase): def test_failfast_py26(self): self.make_26_result() self.assertEqual(False, self.converter.failfast) self.converter.failfast = True self.assertFalse(safe_hasattr(self.converter.decorated, 'f...
class TestExtendedToOriginalResultDecorator( TestExtendedToOriginalResultDecoratorBase):
def test_failfast_py26(self): self.make_26_result() self.assertEqual(False, self.converter.failfast) self.converter.failfast = True self.assertFalse(safe_hasattr(self.converter.decorated, 'failfast')) def test_failfast_py27(self): self.make_27_result() self.asser...
Check that calling a legacy outcome on a fallback works.""" # calling some outcome with the legacy exc_info style api (no keyword # parameters) gets passed through. if not expected: expected = outcome err = sys.exc_info() getattr(self.converter, outcome)(self, err) ...
256
256
906
17
239
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestExtendedToOriginalResultDecorator
TestExtendedToOriginalResultDecorator
2,190
2,309
2,190
2,192
abcae9718d9916666069290dc965b5fe08d6a6ed
bigcode/the-stack
train
d01fe10d0238a8e07035c838
train
class
class TestAdaptedPython26TestResultContract(TestCase, FallbackContract): def makeResult(self): return ExtendedToOriginalDecorator(Python26TestResult())
class TestAdaptedPython26TestResultContract(TestCase, FallbackContract):
def makeResult(self): return ExtendedToOriginalDecorator(Python26TestResult())
Contract(TestCase, StartTestRunContract): def makeResult(self): return ExtendedTestResult() class TestPython26TestResultContract(TestCase, Python26Contract): def makeResult(self): return Python26TestResult() class TestAdaptedPython26TestResultContract(TestCase, FallbackContract):
64
64
34
16
48
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestAdaptedPython26TestResultContract
TestAdaptedPython26TestResultContract
460
463
460
461
f39e98686c591257076bd2d5c365a56ca8c258c8
bigcode/the-stack
train
5e844068fa1c015d932995dd
train
class
class Python26Contract(TestControlContract): def test_fresh_result_is_successful(self): # A result is considered successful before any tests are run. result = self.makeResult() self.assertTrue(result.wasSuccessful()) def test_addError_is_failure(self): # addError fails the test...
class Python26Contract(TestControlContract):
def test_fresh_result_is_successful(self): # A result is considered successful before any tests are run. result = self.makeResult() self.assertTrue(result.wasSuccessful()) def test_addError_is_failure(self): # addError fails the test run. result = self.makeResult() ...
= self.makeResult() self.assertFalse(result.shouldStop) def test_stop_sets_shouldStop(self): # Calling 'stop()' sets 'shouldStop' to True. result = self.makeResult() result.stop() self.assertTrue(result.shouldStop) class Python26Contract(TestControlContract):
64
64
210
8
56
zaneb/testtools
testtools/tests/test_testresult.py
Python
Python26Contract
Python26Contract
155
184
155
156
230ea80cb2c18e2a4911153b3f3d0f0734592567
bigcode/the-stack
train
44ba1cfd27e8195f46bcc3b6
train
class
class TestResourcedToStreamDecorator(TestCase): def setUp(self): super(TestResourcedToStreamDecorator, self).setUp() if testresources is None: self.skipTest('Need testresources') def test_startMakeResource(self): log = LoggingStreamResult() result = ResourcedToStrea...
class TestResourcedToStreamDecorator(TestCase):
def setUp(self): super(TestResourcedToStreamDecorator, self).setUp() if testresources is None: self.skipTest('Need testresources') def test_startMakeResource(self): log = LoggingStreamResult() result = ResourcedToStreamDecorator(log) timestamp = datetime.date...
, None, None, False, None, None, now), ('status', 'testtools.tests.test_testresult.TestExtendedToStreamDecorator.test_empty_detail_status_correct', None, None, True, ...
151
151
506
10
141
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestResourcedToStreamDecorator
TestResourcedToStreamDecorator
943
1,005
943
944
5ad0918990bac8d8c59c5ccabf4805a6c4aa214e
bigcode/the-stack
train
b2f4924af41c98b996a608c7
train
function
def make_mismatching_test(): class Test(TestCase): def mismatch(self): self.assertEqual(1, 2) return Test("mismatch")
def make_mismatching_test():
class Test(TestCase): def mismatch(self): self.assertEqual(1, 2) return Test("mismatch")
class Test(TestCase): def error(self): a = 1 1/0 return Test("error") def make_failing_test(): class Test(TestCase): def failed(self): self.fail("yo!") return Test("failed") def make_mismatching_test():
64
64
35
7
57
zaneb/testtools
testtools/tests/test_testresult.py
Python
make_mismatching_test
make_mismatching_test
112
116
112
112
ebe851857d82c68f9ec4fdbb9f95e37c48bed2ef
bigcode/the-stack
train
64fa2a3997a33ba865ddaab0
train
class
class TestTestControl(TestCase, TestControlContract): def makeResult(self): return TestControl()
class TestTestControl(TestCase, TestControlContract):
def makeResult(self): return TestControl()
StreamSummary() result.startTestRun() result.status("foo.bar", "uxsuccess") self.assertThat(result.unexpectedSuccesses, HasLength(1)) self.assertEqual("foo.bar", result.unexpectedSuccesses[0].id()) class TestTestControl(TestCase, TestControlContract):
64
64
22
11
53
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestTestControl
TestTestControl
1,200
1,203
1,200
1,201
0c6e38b38e1d698b8f3cd60d2a8c67820e120214
bigcode/the-stack
train
607e3d3b43bc97b1662961f1
train
class
class TestBaseStreamResultContract(TestCase, TestStreamResultContract): def _make_result(self): return StreamResult()
class TestBaseStreamResultContract(TestCase, TestStreamResultContract):
def _make_result(self): return StreamResult()
_dicts = [] combos = (combinations(s, r) for r in range(len(s) + 1)) for ss in chain.from_iterable(combos): param_dicts.append(dict(ss)) return param_dicts class TestBaseStreamResultContract(TestCase, TestStreamResultContract):
64
64
26
14
49
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestBaseStreamResultContract
TestBaseStreamResultContract
571
574
571
572
d098d9161e86e49e4bd4c5e04dcee8806b17e9ec
bigcode/the-stack
train
2b45e059d5096c36523a99c1
train
class
class TestExtendedToOriginalAddFailure( TestExtendedToOriginalAddError): outcome = 'addFailure'
class TestExtendedToOriginalAddFailure( TestExtendedToOriginalAddError):
outcome = 'addFailure'
_details(self.outcome) def test_outcome__no_details(self): self.make_extended_result() self.assertThat( lambda: getattr(self.converter, self.outcome)(self), Raises(MatchesException(ValueError))) class TestExtendedToOriginalAddFailure( TestExtendedToOriginalAddError):
63
64
23
16
47
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestExtendedToOriginalAddFailure
TestExtendedToOriginalAddFailure
2,347
2,350
2,347
2,349
ef17b2b2836698f1f20d1b6ee2707f9f45c73ee0
bigcode/the-stack
train
eb241d07f6531cf8c9a24640
train
class
class TestDetailsToStr(TestCase): def test_no_details(self): string = _details_to_str({}) self.assertThat(string, Equals('')) def test_binary_content(self): content = content_from_stream( StringIO('foo'), content_type=ContentType('image', 'jpeg')) string = _details_...
class TestDetailsToStr(TestCase):
def test_no_details(self): string = _details_to_str({}) self.assertThat(string, Equals('')) def test_binary_content(self): content = content_from_stream( StringIO('foo'), content_type=ContentType('image', 'jpeg')) string = _details_to_str({'attachment': content}) ...
output, MatchesRegex( self._as_output(_u( '.*bad.py", line 1\n' '\\s*\\^ = 0 # %s\n' + ' ' * self._error_on_character + '\\s*\\^\n' 'SyntaxError:.*') % text), re.M | re.S) ...
168
168
562
8
160
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestDetailsToStr
TestDetailsToStr
2,779
2,857
2,779
2,780
c42e9c3e800773fdfd5fb44696072f637e9ba57e
bigcode/the-stack
train
b4dabd9927b8810e71d2cf95
train
class
class TestTestResult(TestCase): """Tests for 'TestResult'.""" run_tests_with = FullStackRunTest def makeResult(self): """Make an arbitrary result for testing.""" return TestResult() def test_addSkipped(self): # Calling addSkip on a TestResult records the test that was skipped ...
class TestTestResult(TestCase):
"""Tests for 'TestResult'.""" run_tests_with = FullStackRunTest def makeResult(self): """Make an arbitrary result for testing.""" return TestResult() def test_addSkipped(self): # Calling addSkip on a TestResult records the test that was skipped in # its skip_reasons di...
, HasLength(1)) self.assertEqual("foo.bar", result.errors[0][0].id()) self.assertThat(result.errors[0][1], self.files_message) def test_status_xfail(self): # when xfail is seen, a synthetic test is reported with all files # attached shown as the message. result = StreamSumma...
256
256
1,299
7
249
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestTestResult
TestTestResult
1,206
1,342
1,206
1,206
4528c1da14aa9d7f874259e844d42bc857fc1308
bigcode/the-stack
train
5c0c1dbe1f0b92e151cb9ce1
train
class
class TestExtendedToOriginalAddError(TestExtendedToOriginalResultDecoratorBase): outcome = 'addError' def test_outcome_Original_py26(self): self.make_26_result() self.check_outcome_exc_info(self.outcome) def test_outcome_Original_py27(self): self.make_27_result() self.chec...
class TestExtendedToOriginalAddError(TestExtendedToOriginalResultDecoratorBase):
outcome = 'addError' def test_outcome_Original_py26(self): self.make_26_result() self.check_outcome_exc_info(self.outcome) def test_outcome_Original_py27(self): self.make_27_result() self.check_outcome_exc_info(self.outcome) def test_outcome_Original_pyextended(self): ...
_time_py27(self): self.make_27_result() self.converter.time(1) def test_time_pyextended(self): self.make_extended_result() self.converter.time(1) self.assertEqual([('time', 1)], self.result._events) class TestExtendedToOriginalAddError(TestExtendedToOriginalResultDecoratorBa...
71
71
239
15
56
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestExtendedToOriginalAddError
TestExtendedToOriginalAddError
2,312
2,344
2,312
2,313
37d46c1f81b98f47bde1249cf7523724670d6f12
bigcode/the-stack
train
364953894bcd2c07e2c27b84
train
function
def make_test(): class Test(TestCase): def test(self): pass return Test("test")
def make_test():
class Test(TestCase): def test(self): pass return Test("test")
def mismatch(self): self.assertEqual(1, 2) return Test("mismatch") def make_unexpectedly_successful_test(): class Test(TestCase): def succeeded(self): self.expectFailure("yo!", lambda: None) return Test("succeeded") def make_test():
64
64
24
4
60
zaneb/testtools
testtools/tests/test_testresult.py
Python
make_test
make_test
126
130
126
126
3ea9ee1d538a9eaf3104c9a6b7cd3bd78a3e1270
bigcode/the-stack
train
2064dae6286698240d442bf0
train
class
class TestTextTestResultContract(TestCase, StartTestRunContract): run_test_with = FullStackRunTest def makeResult(self): return TextTestResult(StringIO())
class TestTextTestResultContract(TestCase, StartTestRunContract):
run_test_with = FullStackRunTest def makeResult(self): return TextTestResult(StringIO())
makeResult(self): return TestResult() class TestMultiTestResultContract(TestCase, StartTestRunContract): run_test_with = FullStackRunTest def makeResult(self): return MultiTestResult(TestResult(), TestResult()) class TestTextTestResultContract(TestCase, StartTestRunContract):
64
64
38
14
50
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestTextTestResultContract
TestTextTestResultContract
430
435
430
431
3ca9465d0efa71ab4bb850d612c25f26731d3360
bigcode/the-stack
train
27c8f68ac316356379446860
train
class
class TestMergeTags(TestCase): def test_merge_unseen_gone_tag(self): # If an incoming "gone" tag isn't currently tagged one way or the # other, add it to the "gone" tags. current_tags = set(['present']), set(['missing']) changing_tags = set(), set(['going']) expected = set([...
class TestMergeTags(TestCase):
def test_merge_unseen_gone_tag(self): # If an incoming "gone" tag isn't currently tagged one way or the # other, add it to the "gone" tags. current_tags = set(['present']), set(['missing']) changing_tags = set(), set(['going']) expected = set(['present']), set(['missing', 'go...
# test2 finishes first, and so is flushed first. ('time', start_time2), ('startTest', test2), ('time', end_time2), ('addSuccess', test2), ('stopTest', test2), # test1 finishes next, and thus follows. ('time', start_time1), ...
114
114
381
7
107
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestMergeTags
TestMergeTags
1,848
1,882
1,848
1,849
24dfb0d4d6f62776cc0a301fd7b242ea4bce2a32
bigcode/the-stack
train
713a5611ac0c71483c16a4ef
train
class
class TestStreamSummary(TestCase): def test_attributes(self): result = StreamSummary() result.startTestRun() self.assertEqual([], result.failures) self.assertEqual([], result.errors) self.assertEqual([], result.skipped) self.assertEqual([], result.expectedFailures) ...
class TestStreamSummary(TestCase):
def test_attributes(self): result = StreamSummary() result.startTestRun() self.assertEqual([], result.failures) self.assertEqual([], result.errors) self.assertEqual([], result.skipped) self.assertEqual([], result.expectedFailures) self.assertEqual([], result.u...
(TestCase): def test_inprogress(self): result = StreamFailFast(self.fail) result.status('foo', 'inprogress') def test_exists(self): result = StreamFailFast(self.fail) result.status('foo', 'exists') def test_xfail(self): result = StreamFailFast(self.fail) re...
256
256
1,412
7
249
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestStreamSummary
TestStreamSummary
1,049
1,197
1,049
1,050
41d505495e3ad2dce348db39f6cc771250bc61f5
bigcode/the-stack
train
fc96cbb4c4e783308c40577a
train
class
class TestThreadSafeForwardingResult(TestCase): """Tests for `TestThreadSafeForwardingResult`.""" def make_results(self, n): events = [] target = LoggingResult(events) semaphore = threading.Semaphore(1) return [ ThreadsafeForwardingResult(target, semaphore) ...
class TestThreadSafeForwardingResult(TestCase):
"""Tests for `TestThreadSafeForwardingResult`.""" def make_results(self, n): events = [] target = LoggingResult(events) semaphore = threading.Semaphore(1) return [ ThreadsafeForwardingResult(target, semaphore) for i in range(n)], events def test_nonf...
ows_details(self): self.skip("Disabled per bug 1188420") def run_tests(): self.result.startTestRun() make_erroring_test().run(self.result) make_unexpectedly_successful_test().run(self.result) make_failing_test().run(self.result) self.reset_outp...
256
256
2,144
10
246
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestThreadSafeForwardingResult
TestThreadSafeForwardingResult
1,602
1,845
1,602
1,602
3e67f4d7f23cf43a0f0506f9d9f9c1ded4aedec9
bigcode/the-stack
train
64ec202a639705113449b0fe
train
class
class TestStreamToExtendedContract(TestCase, DetailsContract): def makeResult(self): return ExtendedToStreamDecorator( StreamToExtendedDecorator(ExtendedTestResult()))
class TestStreamToExtendedContract(TestCase, DetailsContract):
def makeResult(self): return ExtendedToStreamDecorator( StreamToExtendedDecorator(ExtendedTestResult()))
ResultDecoratorContract(TestCase, StartTestRunContract): run_test_with = FullStackRunTest def makeResult(self): return TestResultDecorator(TestResult()) # DetailsContract because ExtendedToStreamDecorator follows Python for # uxsuccess handling. class TestStreamToExtendedContract(TestCase, DetailsCo...
64
64
35
12
52
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestStreamToExtendedContract
TestStreamToExtendedContract
500
504
500
501
5f379c7ed2bd562bbb2bbb30e2d6bc7f41a54489
bigcode/the-stack
train
cdf1fada700a53ac17ceafcd
train
function
def make_failing_test(): class Test(TestCase): def failed(self): self.fail("yo!") return Test("failed")
def make_failing_test():
class Test(TestCase): def failed(self): self.fail("yo!") return Test("failed")
testtools.testresult.real import ( _details_to_str, _merge_tags, utc, ) def make_erroring_test(): class Test(TestCase): def error(self): a = 1 1/0 return Test("error") def make_failing_test():
64
64
29
6
58
zaneb/testtools
testtools/tests/test_testresult.py
Python
make_failing_test
make_failing_test
105
109
105
105
df49fac94971ceca189c6a0e0efc6dbca4169723
bigcode/the-stack
train
07bc23372939c173759a9474
train
class
class TestDoubleStreamResultContract(TestCase, TestStreamResultContract): def _make_result(self): return LoggingStreamResult()
class TestDoubleStreamResultContract(TestCase, TestStreamResultContract):
def _make_result(self): return LoggingStreamResult()
StreamResultContract): def _make_result(self): return StreamResult() class TestCopyStreamResultContract(TestCase, TestStreamResultContract): def _make_result(self): return CopyStreamResult([StreamResult(), StreamResult()]) class TestDoubleStreamResultContract(TestCase, TestStreamResultContra...
63
64
27
14
50
zaneb/testtools
testtools/tests/test_testresult.py
Python
TestDoubleStreamResultContract
TestDoubleStreamResultContract
583
586
583
584
c9318ce061d68a07f97a21c91a3659526e2cc6cb
bigcode/the-stack
train
6ba844d6ee4d11c51ccd6ed3
train
class
class BaseProbaDist(ABC): r""" Abstract base class for probability distributions. Check out :class:`coax.proba_dists.CategoricalDist` for a specific example. """ __slots__ = ( '_space', '_sample_func', '_mean_func', '_mode_func', '_log_proba_func', '...
class BaseProbaDist(ABC):
r""" Abstract base class for probability distributions. Check out :class:`coax.proba_dists.CategoricalDist` for a specific example. """ __slots__ = ( '_space', '_sample_func', '_mean_func', '_mode_func', '_log_proba_func', '_entropy_func', '_...
a copy of this software # # and associated documentation files (the "Software"), to deal in the Software without # # restriction, including without limitation the rights to use, copy, modify, merge, publish, # # distribute, sublicense, and/or sell copies of the Software, and to permit persons to w...
256
256
1,739
8
247
sleepy-owl/coax
coax/proba_dists/_base.py
Python
BaseProbaDist
BaseProbaDist
30
349
30
30
9ca61506165d7a82a581c90bb3322f2518329aae
bigcode/the-stack
train
1ce0318a6408500cc1aaea6c
train
function
@register(outgoing=True, pattern=r"^\.aliveu") async def amireallyaliveuser(username): """For .aliveu command, change the username in the .alive command.""" message = username.text if message != ".aliveu" and message[7:8] == " ": newuser = message[8:] global DEFAULTUSER DEFAULTUSER =...
@register(outgoing=True, pattern=r"^\.aliveu") async def amireallyaliveuser(username):
"""For .aliveu command, change the username in the .alive command.""" message = username.text if message != ".aliveu" and message[7:8] == " ": newuser = message[8:] global DEFAULTUSER DEFAULTUSER = newuser await username.edit(f"**Usuário alterado com sucesso para** `{newuser}`**!...
otipo fornecido é inválido**." "\n`Certifique-se de que o link seja direcionado para a imagem do logotipo`" ) else: await alive.edit(output) @register(outgoing=True, pattern=r"^\.aliveu") async def amireallyaliveuser(username):
64
64
108
23
41
ZezinhoRey/PurpleBot
userbot/modules/system_stats.py
Python
amireallyaliveuser
amireallyaliveuser
150
158
150
151
8f2f5635f95612389db174e18fdb1a450680191f
bigcode/the-stack
train
571ac3cb2cd0edbf13a37e91
train
function
@register(outgoing=True, pattern=r"^\.resetalive$") async def amireallyalivereset(ureset): """For .resetalive command, reset the username in the .alive command.""" global DEFAULTUSER DEFAULTUSER = str(ALIVE_NAME) if ALIVE_NAME else uname().node await ureset.edit("**Usuário redefinido com sucesso para o ...
@register(outgoing=True, pattern=r"^\.resetalive$") async def amireallyalivereset(ureset):
"""For .resetalive command, reset the username in the .alive command.""" global DEFAULTUSER DEFAULTUSER = str(ALIVE_NAME) if ALIVE_NAME else uname().node await ureset.edit("**Usuário redefinido com sucesso para o alive!**")
8:] global DEFAULTUSER DEFAULTUSER = newuser await username.edit(f"**Usuário alterado com sucesso para** `{newuser}`**!**") @register(outgoing=True, pattern=r"^\.resetalive$") async def amireallyalivereset(ureset):
64
64
87
27
37
ZezinhoRey/PurpleBot
userbot/modules/system_stats.py
Python
amireallyalivereset
amireallyalivereset
161
166
161
162
ac1e04b30be357c371ad3cf991102fbbde223d7f
bigcode/the-stack
train
7911d495f6ad784e4a5679be
train
function
@register(outgoing=True, pattern=r"^.(alive|on)$") async def amireallyalive(alive): """ For .alive command, check if the bot is running. """ output = ( "`➖➖➖➖➖➖➖➖➖➖➖`\n" f"• 👾 PurpleBot : v{PURPLEBOT_VERSION} \n" f"• ⚙️ Telethon : v{version.__version__} \n" f"• �...
@register(outgoing=True, pattern=r"^.(alive|on)$") async def amireallyalive(alive):
""" For .alive command, check if the bot is running. """ output = ( "`➖➖➖➖➖➖➖➖➖➖➖`\n" f"• 👾 PurpleBot : v{PURPLEBOT_VERSION} \n" f"• ⚙️ Telethon : v{version.__version__} \n" f"• 🐍 Python : v{python_version()} \n" f"• 👤 Usuário : {DEF...
Consulta: **\n`" f"pip3 search {pipmodule}" "`\n**Resultado: **\n`Nenhum resultado encontrado/falso`" ) else: await pip.edit("**Use `.help pip` para ver um exemplo.**") @register(outgoing=True, pattern=r"^.(alive|on)$") async def amireallyalive(alive):
84
84
283
25
59
ZezinhoRey/PurpleBot
userbot/modules/system_stats.py
Python
amireallyalive
amireallyalive
125
147
125
126
a0e630e1d3f8ea46d8475a54e14e4c9a28d569ef
bigcode/the-stack
train
cae5c3b8234d5280996ef640
train
function
@register(outgoing=True, pattern=r"^\.botver$") async def bot_ver(event): """For .botver command, get the bot version.""" if event.text[0].isalpha() or event.text[0] in ("/", "#", "@", "!"): return if which("git") is not None: ver = await asyncrunapp( "git", "describe...
@register(outgoing=True, pattern=r"^\.botver$") async def bot_ver(event):
"""For .botver command, get the bot version.""" if event.text[0].isalpha() or event.text[0] in ("/", "#", "@", "!"): return if which("git") is not None: ver = await asyncrunapp( "git", "describe", "--all", "--long", stdout=asyncPIPE...
await fetch.communicate() result = str(stdout.decode().strip()) + str(stderr.decode().strip()) await sysd.edit("`" + result + "`") except FileNotFoundError: await sysd.edit("**Instale o neofetch primeiro!**") @register(outgoing=True, pattern=r"^\.botver$") async def bot_ver...
78
78
260
20
58
ZezinhoRey/PurpleBot
userbot/modules/system_stats.py
Python
bot_ver
bot_ver
44
74
44
45
1df009f957692d431841df3afff3d3605333bfc1
bigcode/the-stack
train
f311bc47068b8ea48d73b98b
train
function
@register(outgoing=True, pattern=r"^\.pip(?: |$)(.*)") async def pipcheck(pip): """For .pip command, do a pip search.""" if pip.text[0].isalpha() or pip.text[0] in ("/", "#", "@", "!"): return pipmodule = pip.pattern_match.group(1) if pipmodule: await pip.edit("**Procurando...**") ...
@register(outgoing=True, pattern=r"^\.pip(?: |$)(.*)") async def pipcheck(pip):
"""For .pip command, do a pip search.""" if pip.text[0].isalpha() or pip.text[0] in ("/", "#", "@", "!"): return pipmodule = pip.pattern_match.group(1) if pipmodule: await pip.edit("**Procurando...**") pipc = await asyncrunapp( "pip3", "search", ...
PIPE, ) stdout, stderr = await rev.communicate() revout = str(stdout.decode().strip()) + str(stderr.decode().strip()) await event.edit(f"**Versão do Userbot:** `{verout}`\n" f"**Revisão:** `{revout}`\n") else: await event.edit("**Pena que você não tem git!**") @register(outg...
109
109
365
25
84
ZezinhoRey/PurpleBot
userbot/modules/system_stats.py
Python
pipcheck
pipcheck
77
122
77
78
88195d006ee1b3b2abbca9d5b85d90b924683552
bigcode/the-stack
train
65339d194e067d20bd603eb8
train
function
@register(outgoing=True, pattern=r"^\.sysd$") async def sysdetails(sysd): """For .sysd command, get system info using neofetch.""" if not sysd.text[0].isalpha() and sysd.text[0] not in ("/", "#", "@", "!"): try: fetch = await asyncrunapp( "neofetch", "--stdout...
@register(outgoing=True, pattern=r"^\.sysd$") async def sysdetails(sysd):
"""For .sysd command, get system info using neofetch.""" if not sysd.text[0].isalpha() and sysd.text[0] not in ("/", "#", "@", "!"): try: fetch = await asyncrunapp( "neofetch", "--stdout", stdout=asyncPIPE, stderr=asyncPIPE, ...
PURPLEBOT_VERSION, bot from userbot.events import register # ================= CONSTANT ================= DEFAULTUSER = ALIVE_NAME or "Defina a ConfigVar `ALIVE_NAME` !" # ============================================ @register(outgoing=True, pattern=r"^\.sysd$") async def sysdetails(sysd):
64
64
167
21
42
ZezinhoRey/PurpleBot
userbot/modules/system_stats.py
Python
sysdetails
sysdetails
24
41
24
25
a6932df2766f70d6a13f12d85c001b9c1a93e7cc
bigcode/the-stack
train
a56a5cb94983ca494c485b93
train
function
def test_saving_event(hass, hass_recorder): """Test saving and restoring an event.""" hass = hass_recorder() event_type = "EVENT_TEST" event_data = {"test_attr": 5, "test_attr_10": "nice"} events = [] @callback def event_listener(event): """Record events from eventbus.""" ...
def test_saving_event(hass, hass_recorder):
"""Test saving and restoring an event.""" hass = hass_recorder() event_type = "EVENT_TEST" event_data = {"test_attr": 5, "test_attr_10": "nice"} events = [] @callback def event_listener(event): """Record events from eventbus.""" if event.event_type == event_type: ...
.async_set(entity_id, "off", attributes) hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP) hass.bus.async_fire(EVENT_HOMEASSISTANT_FINAL_WRITE) await hass.async_block_till_done() assert "Error executing query" in caplog.text assert "Error saving events" not in caplog.text def test_saving_e...
81
81
273
12
68
calebvisage/core
tests/components/recorder/test_init.py
Python
test_saving_event
test_saving_event
344
382
344
344
ee4f352b0fe60ca1f18844ea7e1fb57d686cc78c
bigcode/the-stack
train
2cdd5f9fce981b86040b4e2a
train
function
def test_saving_state_exclude_domains_globs(hass_recorder): """Test saving and restoring a state.""" hass = hass_recorder( {"exclude": {"domains": "test", "entity_globs": "*.excluded_*"}} ) states = _add_entities( hass, ["test.recorder", "test2.recorder", "test2.excluded_entity"] ) ...
def test_saving_state_exclude_domains_globs(hass_recorder):
"""Test saving and restoring a state.""" hass = hass_recorder( {"exclude": {"domains": "test", "entity_globs": "*.excluded_*"}} ) states = _add_entities( hass, ["test.recorder", "test2.recorder", "test2.excluded_entity"] ) assert len(states) == 1 assert _state_empty_context(h...
states = _add_entities(hass, ["test.recorder", "test2.recorder"]) assert len(states) == 1 assert _state_empty_context(hass, "test2.recorder") == states[0] def test_saving_state_exclude_domains_globs(hass_recorder):
64
64
112
15
49
calebvisage/core
tests/components/recorder/test_init.py
Python
test_saving_state_exclude_domains_globs
test_saving_state_exclude_domains_globs
500
509
500
500
8677bc205e0bb6c75592c1d8820e1828cb5a4351
bigcode/the-stack
train
5c68c137a8840fce7f9d2502
train
function
def test_saving_state_exclude_domains(hass_recorder): """Test saving and restoring a state.""" hass = hass_recorder({"exclude": {"domains": "test"}}) states = _add_entities(hass, ["test.recorder", "test2.recorder"]) assert len(states) == 1 assert _state_empty_context(hass, "test2.recorder") == state...
def test_saving_state_exclude_domains(hass_recorder):
"""Test saving and restoring a state.""" hass = hass_recorder({"exclude": {"domains": "test"}}) states = _add_entities(hass, ["test.recorder", "test2.recorder"]) assert len(states) == 1 assert _state_empty_context(hass, "test2.recorder") == states[0]
", "test", ] } } ) events = _add_events(hass, ["test", "test2"]) assert len(events) == 1 assert events[0].event_type == "test2" def test_saving_state_exclude_domains(hass_recorder):
64
64
87
13
51
calebvisage/core
tests/components/recorder/test_init.py
Python
test_saving_state_exclude_domains
test_saving_state_exclude_domains
492
497
492
492
95eb4f76ba44f1cde957a2e10243e32e9054f63e
bigcode/the-stack
train
b1c76008e3aa824b1d6c66cf
train
function
async def test_database_lock_timeout(hass): """Test locking database timeout when recorder stopped.""" await async_init_recorder_component(hass) hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP) instance: Recorder = hass.data[DATA_INSTANCE] class BlockQueue(recorder.RecorderTask): event: threa...
async def test_database_lock_timeout(hass):
"""Test locking database timeout when recorder stopped.""" await async_init_recorder_component(hass) hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP) instance: Recorder = hass.data[DATA_INSTANCE] class BlockQueue(recorder.RecorderTask): event: threading.Event = threading.Event() def ...
_recording_done(hass, instance) with session_scope(hass=hass) as session: db_events = list(session.query(Events).filter_by(event_type=event_type)) assert len(db_events) == 1 assert not instance.unlock_database() async def test_database_lock_timeout(hass):
64
64
150
9
55
calebvisage/core
tests/components/recorder/test_init.py
Python
test_database_lock_timeout
test_database_lock_timeout
1,362
1,383
1,362
1,362
6bf99d3cf66e04f0142a41473142b5eac5cd62ed
bigcode/the-stack
train
991eb327a480c3513bd7b23b
train
function
def test_saving_state_include_domain_glob_exclude_entity(hass_recorder): """Test saving and restoring a state.""" hass = hass_recorder( { "exclude": {"entities": ["test.recorder", "test2.included_entity"]}, "include": {"domains": "test", "entity_globs": "*._included_*"}, ...
def test_saving_state_include_domain_glob_exclude_entity(hass_recorder):
"""Test saving and restoring a state.""" hass = hass_recorder( { "exclude": {"entities": ["test.recorder", "test2.included_entity"]}, "include": {"domains": "test", "entity_globs": "*._included_*"}, } ) states = _add_entities( hass, ["test.recorder", "test...
"]) assert len(states) == 1 assert _state_empty_context(hass, "test.ok") == states[0] assert _state_empty_context(hass, "test.ok").state == "state2" def test_saving_state_include_domain_glob_exclude_entity(hass_recorder):
64
64
159
17
47
calebvisage/core
tests/components/recorder/test_init.py
Python
test_saving_state_include_domain_glob_exclude_entity
test_saving_state_include_domain_glob_exclude_entity
554
567
554
554
25bab43d7d7b20f6580bebd310c66501991ec408
bigcode/the-stack
train
c9e58dc879c102cd075dccba
train
function
def test_saving_state_exclude_domain_include_entity(hass_recorder): """Test saving and restoring a state.""" hass = hass_recorder( {"include": {"entities": "test.recorder"}, "exclude": {"domains": "test"}} ) states = _add_entities(hass, ["test.recorder", "test2.recorder"]) assert len(states)...
def test_saving_state_exclude_domain_include_entity(hass_recorder):
"""Test saving and restoring a state.""" hass = hass_recorder( {"include": {"entities": "test.recorder"}, "exclude": {"domains": "test"}} ) states = _add_entities(hass, ["test.recorder", "test2.recorder"]) assert len(states) == 2
states = _add_entities(hass, ["test.recorder", "test2.recorder"]) assert len(states) == 1 assert _state_empty_context(hass, "test2.recorder") == states[0] def test_saving_state_exclude_domain_include_entity(hass_recorder):
64
64
84
15
49
calebvisage/core
tests/components/recorder/test_init.py
Python
test_saving_state_exclude_domain_include_entity
test_saving_state_exclude_domain_include_entity
520
526
520
520
27501a6a8ec62d0b635e9b7262f74049dfa292de
bigcode/the-stack
train
e2ad8ea33e2cce3a02cd276e
train
function
def test_saving_state_exclude_domain_glob_include_entity(hass_recorder): """Test saving and restoring a state.""" hass = hass_recorder( { "include": {"entities": ["test.recorder", "test.excluded_entity"]}, "exclude": {"domains": "test", "entity_globs": "*._excluded_*"}, }...
def test_saving_state_exclude_domain_glob_include_entity(hass_recorder):
"""Test saving and restoring a state.""" hass = hass_recorder( { "include": {"entities": ["test.recorder", "test.excluded_entity"]}, "exclude": {"domains": "test", "entity_globs": "*._excluded_*"}, } ) states = _add_entities( hass, ["test.recorder", "test2...
": "test.recorder"}, "exclude": {"domains": "test"}} ) states = _add_entities(hass, ["test.recorder", "test2.recorder"]) assert len(states) == 2 def test_saving_state_exclude_domain_glob_include_entity(hass_recorder):
64
64
116
17
46
calebvisage/core
tests/components/recorder/test_init.py
Python
test_saving_state_exclude_domain_glob_include_entity
test_saving_state_exclude_domain_glob_include_entity
529
540
529
529
b20088f5886c411e93cf8eb00dd6208f26d7ca0c
bigcode/the-stack
train
5c7c9fdde5dc04aeeaffa1de
train
function
async def test_force_shutdown_with_queue_of_writes_that_generate_exceptions( hass, async_setup_recorder_instance, caplog ): """Test forcing shutdown.""" instance = await async_setup_recorder_instance(hass) entity_id = "test.recorder" attributes = {"test_attr": 5, "test_attr_10": "nice"} await ...
async def test_force_shutdown_with_queue_of_writes_that_generate_exceptions( hass, async_setup_recorder_instance, caplog ):
"""Test forcing shutdown.""" instance = await async_setup_recorder_instance(hass) entity_id = "test.recorder" attributes = {"test_attr": 5, "test_attr_10": "nice"} await async_wait_recording_done(hass, instance) with patch.object(instance, "db_retry_wait", 0.05), patch.object( instanc...
assert "Error executing query" not in caplog.text assert "Error saving events" not in caplog.text assert "SQLAlchemyError error processing task" not in caplog.text async def test_force_shutdown_with_queue_of_writes_that_generate_exceptions( hass, async_setup_recorder_instance, caplog ):
69
69
233
28
40
calebvisage/core
tests/components/recorder/test_init.py
Python
test_force_shutdown_with_queue_of_writes_that_generate_exceptions
test_force_shutdown_with_queue_of_writes_that_generate_exceptions
314
341
314
316
0a785cde2ca298f9223d34e340e6347e4a0fa88b
bigcode/the-stack
train
cdf93f9b4319d37ec7eff63c
train
function
async def test_defaults_set(hass): """Test the config defaults are set.""" recorder_config = None async def mock_setup(hass, config): """Mock setup.""" nonlocal recorder_config recorder_config = config["recorder"] return True with patch("homeassistant.components.recorde...
async def test_defaults_set(hass):
"""Test the config defaults are set.""" recorder_config = None async def mock_setup(hass, config): """Mock setup.""" nonlocal recorder_config recorder_config = config["recorder"] return True with patch("homeassistant.components.recorder.async_setup", side_effect=mock_se...
, "_setup_connection") as setup, patch( "homeassistant.components.recorder.time.sleep" ): setup.side_effect = ImportError("driver not found") rec = _default_recorder(hass) rec.start() rec.join() hass.stop() async def test_defaults_set(hass):
64
64
141
8
56
calebvisage/core
tests/components/recorder/test_init.py
Python
test_defaults_set
test_defaults_set
618
635
618
618
7cc11abb15081b1ff8dbe8a442cbc2f0147eb539
bigcode/the-stack
train
31e6a85052f250f65fbee651
train
function
@pytest.mark.parametrize("enable_nightly_purge", [True]) def test_auto_purge_disabled(hass_recorder): """Test periodic db cleanup still run when auto purge is disabled.""" hass = hass_recorder({CONF_AUTO_PURGE: False}) original_tz = dt_util.DEFAULT_TIME_ZONE tz = dt_util.get_time_zone("Europe/Copenhag...
@pytest.mark.parametrize("enable_nightly_purge", [True]) def test_auto_purge_disabled(hass_recorder):
"""Test periodic db cleanup still run when auto purge is disabled.""" hass = hass_recorder({CONF_AUTO_PURGE: False}) original_tz = dt_util.DEFAULT_TIME_ZONE tz = dt_util.get_time_zone("Europe/Copenhagen") dt_util.set_default_time_zone(tz) # Purging is scheduled to happen at 4:12am every day. ...
run_tasks_at_time(hass, test_time) assert len(purge_old_data.mock_calls) == 1 args, _ = purge_old_data.call_args_list[0] assert args[2] is False # repack assert len(perodic_db_cleanups.mock_calls) == 1 dt_util.set_default_time_zone(original_tz) @pytest.mark.parametrize("ena...
103
103
346
24
79
calebvisage/core
tests/components/recorder/test_init.py
Python
test_auto_purge_disabled
test_auto_purge_disabled
817
850
817
818
97bd1a5f7bb55cd9dbaff396ba99f62a74c3da07
bigcode/the-stack
train
fa5d2cf7d4da465509a24236
train
function
async def test_database_lock_and_unlock(hass: HomeAssistant, tmp_path): """Test writing events during lock getting written after unlocking.""" # Use file DB, in memory DB cannot do write locks. config = {recorder.CONF_DB_URL: "sqlite:///" + str(tmp_path / "pytest.db")} await async_init_recorder_componen...
async def test_database_lock_and_unlock(hass: HomeAssistant, tmp_path):
"""Test writing events during lock getting written after unlocking.""" # Use file DB, in memory DB cannot do write locks. config = {recorder.CONF_DB_URL: "sqlite:///" + str(tmp_path / "pytest.db")} await async_init_recorder_component(hass, config) await hass.async_block_till_done() instance: Re...
", data) wait_recording_done(hass) with session_scope(hass=hass) as session: db_events = list(session.query(Events).filter_by(event_type="hello")) # Keep referring idx + 1, as no new events are being added assert len(db_events) == idx + 1, data async def test_databas...
87
87
292
16
70
calebvisage/core
tests/components/recorder/test_init.py
Python
test_database_lock_and_unlock
test_database_lock_and_unlock
1,299
1,330
1,299
1,299
6c986e679f679a380e84cc3f3684fbdccfa75b0f
bigcode/the-stack
train
8bf27476f45c71fa1d3d3bb6
train
function
def test_has_services(hass_recorder): """Test the services exist.""" hass = hass_recorder() assert hass.services.has_service(DOMAIN, SERVICE_DISABLE) assert hass.services.has_service(DOMAIN, SERVICE_ENABLE) assert hass.services.has_service(DOMAIN, SERVICE_PURGE) assert hass.services.has_service...
def test_has_services(hass_recorder):
"""Test the services exist.""" hass = hass_recorder() assert hass.services.has_service(DOMAIN, SERVICE_DISABLE) assert hass.services.has_service(DOMAIN, SERVICE_ENABLE) assert hass.services.has_service(DOMAIN, SERVICE_PURGE) assert hass.services.has_service(DOMAIN, SERVICE_PURGE_ENTITIES)
False run_info = run_information(hass, before_start_recording) assert run_info is None run_info = run_information(hass, dt_util.utcnow()) assert isinstance(run_info, RecorderRuns) assert run_info.closed_incorrect is False def test_has_services(hass_recorder):
64
64
79
9
54
calebvisage/core
tests/components/recorder/test_init.py
Python
test_has_services
test_has_services
1,048
1,055
1,048
1,048
99f837f67c6631a31319b9e7c35ade95d6994a8a
bigcode/the-stack
train
82af3cacc979fb9913a4d16b
train
function
async def test_shutdown_before_startup_finishes(hass): """Test shutdown before recorder starts is clean.""" hass.state = CoreState.not_running await async_init_recorder_component(hass) await hass.data[DATA_INSTANCE].async_db_ready await hass.async_block_till_done() session = await hass.async_...
async def test_shutdown_before_startup_finishes(hass):
"""Test shutdown before recorder starts is clean.""" hass.state = CoreState.not_running await async_init_recorder_component(hass) await hass.data[DATA_INSTANCE].async_db_ready await hass.async_block_till_done() session = await hass.async_add_executor_job(hass.data[DATA_INSTANCE].get_session) ...
commit_interval=1, uri="sqlite://", db_max_retries=10, db_retry_wait=3, entity_filter=CONFIG_SCHEMA({DOMAIN: {}}), exclude_t=[], exclude_attributes_by_domain={}, ) async def test_shutdown_before_startup_finishes(hass):
64
64
167
12
52
calebvisage/core
tests/components/recorder/test_init.py
Python
test_shutdown_before_startup_finishes
test_shutdown_before_startup_finishes
86
106
86
86
8916332d8f1eb477f8caa63e0fd2b54a969987c2
bigcode/the-stack
train
8c34428a20805f1c3f5953b7
train
function
def test_saving_state_include_domains(hass_recorder): """Test saving and restoring a state.""" hass = hass_recorder({"include": {"domains": "test2"}}) states = _add_entities(hass, ["test.recorder", "test2.recorder"]) assert len(states) == 1 assert _state_empty_context(hass, "test2.recorder") == stat...
def test_saving_state_include_domains(hass_recorder):
"""Test saving and restoring a state.""" hass = hass_recorder({"include": {"domains": "test2"}}) states = _add_entities(hass, ["test.recorder", "test2.recorder"]) assert len(states) == 1 assert _state_empty_context(hass, "test2.recorder") == states[0]
it by joining the # events table on the event_id for state_changed events state = hass.states.get(entity_id) state.context = Context(id=None) return state # pylint: disable=redefined-outer-name,invalid-name def test_saving_state_include_domains(hass_recorder):
64
64
87
12
51
calebvisage/core
tests/components/recorder/test_init.py
Python
test_saving_state_include_domains
test_saving_state_include_domains
442
447
442
442
44a74df5698ee2dc458ee0e9559e34f01c390912
bigcode/the-stack
train
972e6283338cef0bc3bcf833
train
function
async def test_saving_many_states( hass: HomeAssistant, async_setup_recorder_instance: SetupRecorderInstanceT ): """Test we expire after many commits.""" instance = await async_setup_recorder_instance( hass, {recorder.CONF_COMMIT_INTERVAL: 1} ) entity_id = "test.recorder" attributes = {...
async def test_saving_many_states( hass: HomeAssistant, async_setup_recorder_instance: SetupRecorderInstanceT ):
"""Test we expire after many commits.""" instance = await async_setup_recorder_instance( hass, {recorder.CONF_COMMIT_INTERVAL: 1} ) entity_id = "test.recorder" attributes = {"test_attr": 5, "test_attr_10": "nice"} with patch.object( hass.data[DATA_INSTANCE].event_session, "expi...
.attributes = db_state_attributes.to_native() assert len(db_states) == 1 assert db_states[0].event_id > 0 assert state == _state_empty_context(hass, entity_id) async def test_saving_many_states( hass: HomeAssistant, async_setup_recorder_instance: SetupRecorderInstanceT ):
71
71
239
26
45
calebvisage/core
tests/components/recorder/test_init.py
Python
test_saving_many_states
test_saving_many_states
184
209
184
186
1aafaa5258658e2297e015ba55dd1bf30b07bbe1
bigcode/the-stack
train
af54b04eb3b4d9871d9f1ef9
train
function
def test_saving_state_incl_entities(hass_recorder): """Test saving and restoring a state.""" hass = hass_recorder({"include": {"entities": "test2.recorder"}}) states = _add_entities(hass, ["test.recorder", "test2.recorder"]) assert len(states) == 1 assert _state_empty_context(hass, "test2.recorder")...
def test_saving_state_incl_entities(hass_recorder):
"""Test saving and restoring a state.""" hass = hass_recorder({"include": {"entities": "test2.recorder"}}) states = _add_entities(hass, ["test.recorder", "test2.recorder"]) assert len(states) == 1 assert _state_empty_context(hass, "test2.recorder") == states[0]
) assert len(states) == 2 assert _state_empty_context(hass, "test2.recorder") == states[0] assert _state_empty_context(hass, "test3.included_entity") == states[1] def test_saving_state_incl_entities(hass_recorder):
64
64
90
13
51
calebvisage/core
tests/components/recorder/test_init.py
Python
test_saving_state_incl_entities
test_saving_state_incl_entities
463
468
463
463
57c3bc2328d676fdaad8c9b07d2fff62e50809b9
bigcode/the-stack
train
a4bf57653fc1e7d61c599e97
train
function
def test_saving_event_exclude_event_type(hass_recorder): """Test saving and restoring an event.""" hass = hass_recorder( { "exclude": { "event_types": [ "service_registered", "homeassistant_start", "component_loaded"...
def test_saving_event_exclude_event_type(hass_recorder):
"""Test saving and restoring an event.""" hass = hass_recorder( { "exclude": { "event_types": [ "service_registered", "homeassistant_start", "component_loaded", "core_config_updated", ...
) states = _add_entities(hass, ["test.recorder", "test2.recorder"]) assert len(states) == 1 assert _state_empty_context(hass, "test2.recorder") == states[0] def test_saving_event_exclude_event_type(hass_recorder):
64
64
121
14
50
calebvisage/core
tests/components/recorder/test_init.py
Python
test_saving_event_exclude_event_type
test_saving_event_exclude_event_type
471
489
471
471
baf943264222b70b2fa24aa147a1ac0674b3b293
bigcode/the-stack
train
2f67a6b0a790ad94862ae91c
train
function
def run_tasks_at_time(hass, test_time): """Advance the clock and wait for any callbacks to finish.""" fire_time_changed(hass, test_time) hass.block_till_done() hass.data[DATA_INSTANCE].block_till_done()
def run_tasks_at_time(hass, test_time):
"""Advance the clock and wait for any callbacks to finish.""" fire_time_changed(hass, test_time) hass.block_till_done() hass.data[DATA_INSTANCE].block_till_done()
) assert recorder_config is not None # pylint: disable=unsubscriptable-object assert recorder_config["auto_purge"] assert recorder_config["auto_repack"] assert recorder_config["purge_keep_days"] == 10 def run_tasks_at_time(hass, test_time):
64
64
53
11
52
calebvisage/core
tests/components/recorder/test_init.py
Python
run_tasks_at_time
run_tasks_at_time
638
642
638
638
846a7ca40306f1794a4f014dc59fbd7f5157b508
bigcode/the-stack
train
a566e26c1521d3a48a3d066c
train
function
@pytest.mark.parametrize("enable_nightly_purge", [True]) def test_auto_purge_auto_repack_on_second_sunday(hass_recorder): """Test periodic purge scheduling does a repack on the 2nd sunday.""" hass = hass_recorder() original_tz = dt_util.DEFAULT_TIME_ZONE tz = dt_util.get_time_zone("Europe/Copenhagen")...
@pytest.mark.parametrize("enable_nightly_purge", [True]) def test_auto_purge_auto_repack_on_second_sunday(hass_recorder):
"""Test periodic purge scheduling does a repack on the 2nd sunday.""" hass = hass_recorder() original_tz = dt_util.DEFAULT_TIME_ZONE tz = dt_util.get_time_zone("Europe/Copenhagen") dt_util.set_default_time_zone(tz) # Purging is scheduled to happen at 4:12am every day. Exercise this behavior b...
ic_db_cleanups.mock_calls) == 0 # Advance to the next day and fire the alarm again test_time = test_time + timedelta(hours=1) run_tasks_at_time(hass, test_time) assert len(purge_old_data.mock_calls) == 1 assert len(perodic_db_cleanups.mock_calls) == 1 dt_util.set_default_ti...
118
118
394
30
88
calebvisage/core
tests/components/recorder/test_init.py
Python
test_auto_purge_auto_repack_on_second_sunday
test_auto_purge_auto_repack_on_second_sunday
703
738
703
704
0f5c2c5443a1176f17b80d9206fbb10b128545f1
bigcode/the-stack
train
7ec064dd82cdf137e4acf3e5
train
function
def test_saving_state_exclude_entities(hass_recorder): """Test saving and restoring a state.""" hass = hass_recorder({"exclude": {"entities": "test.recorder"}}) states = _add_entities(hass, ["test.recorder", "test2.recorder"]) assert len(states) == 1 assert _state_empty_context(hass, "test2.recorder...
def test_saving_state_exclude_entities(hass_recorder):
"""Test saving and restoring a state.""" hass = hass_recorder({"exclude": {"entities": "test.recorder"}}) states = _add_entities(hass, ["test.recorder", "test2.recorder"]) assert len(states) == 1 assert _state_empty_context(hass, "test2.recorder") == states[0]
hass, ["test.recorder", "test2.recorder", "test2.excluded_entity"] ) assert len(states) == 1 assert _state_empty_context(hass, "test2.recorder") == states[0] def test_saving_state_exclude_entities(hass_recorder):
64
64
89
13
51
calebvisage/core
tests/components/recorder/test_init.py
Python
test_saving_state_exclude_entities
test_saving_state_exclude_entities
512
517
512
512
b0f45765005cd1a361de02f7112239a3b0ff96b5
bigcode/the-stack
train
5b08afd0aa250d11bf7e6d99
train
class
class CannotSerializeMe: """A class that the JSONEncoder cannot serialize."""
class CannotSerializeMe:
"""A class that the JSONEncoder cannot serialize."""
== 2 assert db_run_info[0].start is not None assert db_run_info[0].end is not None assert db_run_info[1].start is not None assert db_run_info[1].end is None hass.stop() class CannotSerializeMe:
64
64
16
5
59
calebvisage/core
tests/components/recorder/test_init.py
Python
CannotSerializeMe
CannotSerializeMe
1,198
1,199
1,198
1,198
960f4b290b4af228e838284ca935241589d008fd
bigcode/the-stack
train
335cb10fa10cfa3726d5b04c
train
function
def test_statistics_runs_initiated(hass_recorder): """Test statistics_runs is initiated when DB is created.""" now = dt_util.utcnow() with patch("homeassistant.components.recorder.dt_util.utcnow", return_value=now): hass = hass_recorder() wait_recording_done(hass) with session_scop...
def test_statistics_runs_initiated(hass_recorder):
"""Test statistics_runs is initiated when DB is created.""" now = dt_util.utcnow() with patch("homeassistant.components.recorder.dt_util.utcnow", return_value=now): hass = hass_recorder() wait_recording_done(hass) with session_scope(hass=hass) as session: statistics_run...
task should run again test_time = test_time + timedelta(minutes=5) run_tasks_at_time(hass, test_time) assert len(compile_statistics.mock_calls) == 1 dt_util.set_default_time_zone(original_tz) def test_statistics_runs_initiated(hass_recorder):
64
64
152
12
52
calebvisage/core
tests/components/recorder/test_init.py
Python
test_statistics_runs_initiated
test_statistics_runs_initiated
904
918
904
904
45f7f0e349427ecdf519857e660c5c604fc2229b
bigcode/the-stack
train
7f36fdc36bf284645946c1e8
train
function
def _state_empty_context(hass, entity_id): # We don't restore context unless we need it by joining the # events table on the event_id for state_changed events state = hass.states.get(entity_id) state.context = Context(id=None) return state
def _state_empty_context(hass, entity_id): # We don't restore context unless we need it by joining the # events table on the event_id for state_changed events
state = hass.states.get(entity_id) state.context = Context(id=None) return state
session_scope(hass=hass) as session: return [ev.to_native() for ev in session.query(Events)] def _state_empty_context(hass, entity_id): # We don't restore context unless we need it by joining the # events table on the event_id for state_changed events
63
64
59
38
25
calebvisage/core
tests/components/recorder/test_init.py
Python
_state_empty_context
_state_empty_context
433
438
433
435
fe76d1aecc091aa9f35b0ee85477ded00c49c52a
bigcode/the-stack
train
351712a15bbad519c3540950
train
function
def test_saving_sets_old_state(hass_recorder): """Test saving sets old state.""" hass = hass_recorder() hass.states.set("test.one", "on", {}) hass.states.set("test.two", "on", {}) wait_recording_done(hass) hass.states.set("test.one", "off", {}) hass.states.set("test.two", "off", {}) wai...
def test_saving_sets_old_state(hass_recorder):
"""Test saving sets old state.""" hass = hass_recorder() hass.states.set("test.one", "on", {}) hass.states.set("test.two", "on", {}) wait_recording_done(hass) hass.states.set("test.one", "off", {}) hass.states.set("test.two", "off", {}) wait_recording_done(hass) with session_scope(...
(statistics_runs) == 13 # 12 5-minute runs last_run = process_timestamp(statistics_runs[1].start) assert last_run == now wait_recording_done(hass) wait_recording_done(hass) hass.stop() def test_saving_sets_old_state(hass_recorder):
69
69
231
12
57
calebvisage/core
tests/components/recorder/test_init.py
Python
test_saving_sets_old_state
test_saving_sets_old_state
967
990
967
967
d0f0eb293f60081cf03d3a7b825561f246c73238
bigcode/the-stack
train
0edc59257bfcc3c4a279b648
train
function
async def test_saving_state_with_intermixed_time_changes( hass: HomeAssistant, async_setup_recorder_instance: SetupRecorderInstanceT ): """Test saving states with intermixed time changes.""" instance = await async_setup_recorder_instance(hass) entity_id = "test.recorder" state = "restoring_from_db"...
async def test_saving_state_with_intermixed_time_changes( hass: HomeAssistant, async_setup_recorder_instance: SetupRecorderInstanceT ):
"""Test saving states with intermixed time changes.""" instance = await async_setup_recorder_instance(hass) entity_id = "test.recorder" state = "restoring_from_db" attributes = {"test_attr": 5, "test_attr_10": "nice"} attributes2 = {"test_attr": 10, "test_attr_10": "mean"} for _ in range(K...
_scope(hass=hass) as session: db_states = list(session.query(States)) assert len(db_states) == 6 assert db_states[0].event_id > 0 async def test_saving_state_with_intermixed_time_changes( hass: HomeAssistant, async_setup_recorder_instance: SetupRecorderInstanceT ):
73
73
245
31
41
calebvisage/core
tests/components/recorder/test_init.py
Python
test_saving_state_with_intermixed_time_changes
test_saving_state_with_intermixed_time_changes
212
235
212
214
47a9152a9d13924c3223d064bd0e731cd856f597
bigcode/the-stack
train
5a2f7cac645708b6c19a3b28
train
function
async def test_state_gets_saved_when_set_before_start_event( hass: HomeAssistant, async_setup_recorder_instance: SetupRecorderInstanceT ): """Test we can record an event when starting with not running.""" hass.state = CoreState.not_running await async_init_recorder_component(hass) entity_id = "te...
async def test_state_gets_saved_when_set_before_start_event( hass: HomeAssistant, async_setup_recorder_instance: SetupRecorderInstanceT ):
"""Test we can record an event when starting with not running.""" hass.state = CoreState.not_running await async_init_recorder_component(hass) entity_id = "test.recorder" state = "restoring_from_db" attributes = {"test_attr": 5, "test_attr_10": "nice"} hass.states.async_set(entity_id, st...
hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP) await hass.async_block_till_done() assert len(pool.shutdown.mock_calls) == 1 async def test_state_gets_saved_when_set_before_start_event( hass: HomeAssistant, async_setup_recorder_instance: SetupRecorderInstanceT ):
64
64
182
31
32
calebvisage/core
tests/components/recorder/test_init.py
Python
test_state_gets_saved_when_set_before_start_event
test_state_gets_saved_when_set_before_start_event
133
155
133
135
f077c98d7219c496a024ffbdca3a01dba820b2b1
bigcode/the-stack
train
e6ea36f6805ba7ec23256b74
train
function
def _add_entities(hass, entity_ids): """Add entities.""" attributes = {"test_attr": 5, "test_attr_10": "nice"} for idx, entity_id in enumerate(entity_ids): hass.states.set(entity_id, f"state{idx}", attributes) wait_recording_done(hass) with session_scope(hass=hass) as session: state...
def _add_entities(hass, entity_ids):
"""Add entities.""" attributes = {"test_attr": 5, "test_attr_10": "nice"} for idx, entity_id in enumerate(entity_ids): hass.states.set(entity_id, f"state{idx}", attributes) wait_recording_done(hass) with session_scope(hass=hass) as session: states = [] for state, state_attri...
) wait_recording_done(hass) with session_scope(hass=hass) as session: db_states = list(session.query(States)) assert len(db_states) == 1 assert db_states[0].event_id > 0 def _add_entities(hass, entity_ids):
64
64
145
10
53
calebvisage/core
tests/components/recorder/test_init.py
Python
_add_entities
_add_entities
404
419
404
404
5fedb7ff3334b7bb01efc25022da23091d0d9e23
bigcode/the-stack
train
da46a541859edb024edba9e4
train
function
@pytest.mark.parametrize("enable_statistics", [True]) def test_auto_statistics(hass_recorder): """Test periodic statistics scheduling.""" hass = hass_recorder() original_tz = dt_util.DEFAULT_TIME_ZONE tz = dt_util.get_time_zone("Europe/Copenhagen") dt_util.set_default_time_zone(tz) # Statisti...
@pytest.mark.parametrize("enable_statistics", [True]) def test_auto_statistics(hass_recorder):
"""Test periodic statistics scheduling.""" hass = hass_recorder() original_tz = dt_util.DEFAULT_TIME_ZONE tz = dt_util.get_time_zone("Europe/Copenhagen") dt_util.set_default_time_zone(tz) # Statistics is scheduled to happen every 5 minutes. Exercise this behavior by # firing time changed ...
.recorder.perodic_db_cleanups" ) as perodic_db_cleanups: # Advance one day, and the purge task should run test_time = test_time + timedelta(days=1) run_tasks_at_time(hass, test_time) assert len(purge_old_data.mock_calls) == 0 assert len(perodic_db_cleanups.mock_calls) == 1 ...
132
132
441
19
113
calebvisage/core
tests/components/recorder/test_init.py
Python
test_auto_statistics
test_auto_statistics
853
901
853
854
fa583bf66d60a4aa1c219c4d7e685490553a524e
bigcode/the-stack
train
f73c6fa60aa99164d3888a0e
train
function
def test_run_information(hass_recorder): """Ensure run_information returns expected data.""" before_start_recording = dt_util.utcnow() hass = hass_recorder() run_info = run_information_from_instance(hass) assert isinstance(run_info, RecorderRuns) assert run_info.closed_incorrect is False wi...
def test_run_information(hass_recorder):
"""Ensure run_information returns expected data.""" before_start_recording = dt_util.utcnow() hass = hass_recorder() run_info = run_information_from_instance(hass) assert isinstance(run_info, RecorderRuns) assert run_info.closed_incorrect is False with session_scope(hass=hass) as session: ...
"test.two" assert states[1].entity_id == "test.two" assert states[0].old_state_id is None assert states[1].old_state_id == states[0].state_id assert "State is not JSON serializable" in caplog.text def test_run_information(hass_recorder):
70
70
235
9
60
calebvisage/core
tests/components/recorder/test_init.py
Python
test_run_information
test_run_information
1,017
1,045
1,017
1,017
a9810731f30e56c1f03d26106eb2829de65f686e
bigcode/the-stack
train