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
de064ec11756d440d939b99e
train
function
@cooldown(seconds=2700) def send_sell_xlm_sms(): _msg = "Good time to convert XLM into stablecoin" _subj = "STABLE COIN XLM" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send)
@cooldown(seconds=2700) def send_sell_xlm_sms():
_msg = "Good time to convert XLM into stablecoin" _subj = "STABLE COIN XLM" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send)
_subj = "STABLE COIN DASH" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send) @cooldown(seconds=2700) def send_sell_xlm_sms():
64
64
81
16
48
RaymondTerry/SignalBot
SignalBot/sms_api.py
Python
send_sell_xlm_sms
send_sell_xlm_sms
294
300
294
296
204c0192cd862804e20f943a225297e87a364e65
bigcode/the-stack
train
7dac528ca70f936eef6c1516
train
function
@cooldown(seconds=2700) def send_buy_xlm_sms(): _msg = "Good time to DCA into XLM" _subj = "DCA XLM" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send)
@cooldown(seconds=2700) def send_buy_xlm_sms():
_msg = "Good time to DCA into XLM" _subj = "DCA XLM" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send)
" _subj = "DCA DASH" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send) @cooldown(seconds=2700) def send_buy_xlm_sms():
64
64
78
16
48
RaymondTerry/SignalBot
SignalBot/sms_api.py
Python
send_buy_xlm_sms
send_buy_xlm_sms
205
211
205
207
a85ac6d30ff7cd7990a685d60cdb017d3a68ce71
bigcode/the-stack
train
92bef76573c93d52af2a4562
train
function
@cooldown(seconds=2700) def send_bch_sms(): _msg = " BCH NEAR TARGET" _subj = "BCH NEAR TARGET" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send)
@cooldown(seconds=2700) def send_bch_sms():
_msg = " BCH NEAR TARGET" _subj = "BCH NEAR TARGET" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send)
_subj = "XRP NEAR TARGET" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send) @cooldown(seconds=2700) def send_bch_sms():
64
64
75
15
49
RaymondTerry/SignalBot
SignalBot/sms_api.py
Python
send_bch_sms
send_bch_sms
68
74
68
70
19bbcfeecd15337d731a2b9e6fbca5ee63bce1d7
bigcode/the-stack
train
b66999f8bb5f95cdaa196258
train
function
@cooldown(seconds=2700) def send_buy_link_sms(): _msg = "Good time to DCA into LINK" _subj = "DCA LINK" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send)
@cooldown(seconds=2700) def send_buy_link_sms():
_msg = "Good time to DCA into LINK" _subj = "DCA LINK" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send)
ETH" _subj = "DCA ETH" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send) @cooldown(seconds=2700) def send_buy_link_sms():
64
64
75
15
49
RaymondTerry/SignalBot
SignalBot/sms_api.py
Python
send_buy_link_sms
send_buy_link_sms
232
238
232
234
c9b6b0a84cfb3d61b72a647f98e1871b8c610da3
bigcode/the-stack
train
8964f093be17511a795a7205
train
function
@cooldown(seconds=2700) def send_buy_btc_sms(): _msg = "Good time to DCA into BTC" _subj = "DCA BTC" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send)
@cooldown(seconds=2700) def send_buy_btc_sms():
_msg = "Good time to DCA into BTC" _subj = "DCA BTC" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send)
_subj = "DCA XLM" send = send_txt(sms_auth.NUMBER, sms_auth.CARRIER, sms_auth.EMAIL, sms_auth.PASS, _msg, _subj) asyncio.run(send) @cooldown(seconds=2700) def send_buy_btc_sms():
64
64
76
16
48
RaymondTerry/SignalBot
SignalBot/sms_api.py
Python
send_buy_btc_sms
send_buy_btc_sms
214
220
214
216
af0f53c862b4c124cecea41d26bdcd907c2b1305
bigcode/the-stack
train
3596b2a68e4d3748666b6c0e
train
function
def test_prefix(): actual = logs.prefix("TEST STRING", "deploy") assert "TEST STRING" in actual
def test_prefix():
actual = logs.prefix("TEST STRING", "deploy") assert "TEST STRING" in actual
_effect = LOG_COMPONENTS.__getitem__ actual = logs.ScribeLogReader( cluster_map=cluster_map ).determine_scribereader_envs(components, cluster) assert "fake_scribe_env" in actual and "fake_scribe_env2" in actual def test_prefix():
64
64
25
4
59
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_prefix
test_prefix
1,068
1,070
1,068
1,068
acb92e2c0d6286296c220c88da7ebda4c570ef10
bigcode/the-stack
train
a5c96b2facbfe4d0438c7c26
train
function
def test_prettify_component_valid(): component = "build" actual = logs.prettify_component(component) assert component in actual assert "UNPRETTIFIABLE COMPONENT" not in actual
def test_prettify_component_valid():
component = "build" actual = logs.prettify_component(component) assert component in actual assert "UNPRETTIFIABLE COMPONENT" not in actual
and I tried to get python to recognize a hardcoded timezone # in TZ, even using tzset(), but it ignored us. So we're punting. assert "2015-03-12 " in actual assert ":20:04" in actual def test_prettify_component_valid():
64
64
44
8
55
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_prettify_component_valid
test_prettify_component_valid
603
607
603
603
6e7cd329f811697442d7a6b3ce44f23b17f3b931
bigcode/the-stack
train
6bf83d04f6e105b3adce2741
train
function
def test_prettify_component_invalid(): component = "non-existent component" actual = logs.prettify_component(component) assert component in actual assert "UNPRETTIFIABLE COMPONENT" in actual
def test_prettify_component_invalid():
component = "non-existent component" actual = logs.prettify_component(component) assert component in actual assert "UNPRETTIFIABLE COMPONENT" in actual
actual assert ":20:04" in actual def test_prettify_component_valid(): component = "build" actual = logs.prettify_component(component) assert component in actual assert "UNPRETTIFIABLE COMPONENT" not in actual def test_prettify_component_invalid():
64
64
45
8
55
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_prettify_component_invalid
test_prettify_component_invalid
610
614
610
610
372a240dd14c36b61380356dea5412d407355b6f
bigcode/the-stack
train
3d615bb7f88266a63d644800
train
function
@pytest.mark.skipif( not scribereader_available, reason="scribereader not available" ) # pragma: no cover (yelpy) def test_scribe_tail_log_everything(): env = "fake_env" stream_name = "fake_stream" service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["build", "deploy"]...
@pytest.mark.skipif( not scribereader_available, reason="scribereader not available" ) # pragma: no cover (yelpy) def test_scribe_tail_log_everything():
env = "fake_env" stream_name = "fake_stream" service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["build", "deploy"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" queue = Queue() filter_fn = mock.Mock(return_value=True) tailer...
log test message" % fake_timestamp clusters = ["fake_cluster"] expected = json.dumps( { "timestamp": fake_utc_timestamp, "component": "marathon", "cluster": clusters[0], "service": fake_service, "instance": "ALL", "level": "event", ...
144
144
482
40
104
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_scribe_tail_log_everything
test_scribe_tail_log_everything
418
473
418
421
9189f5541e032861cbf6dde9c061f7a5776d2751
bigcode/the-stack
train
38a2dbb79572fe1941cb1c55
train
function
def test_validate_filtering_args_with_invalid_inputs(): fake_reader = logs.LogReader() fake_reader.SUPPORTS_TAILING = False args, _ = parse_args(["logs", "--tail"]) assert not logs.validate_filtering_args(args, fake_reader) fake_reader.SUPPORTS_TIME = False args, _ = parse_args(["logs", "--fro...
def test_validate_filtering_args_with_invalid_inputs():
fake_reader = logs.LogReader() fake_reader.SUPPORTS_TAILING = False args, _ = parse_args(["logs", "--tail"]) assert not logs.validate_filtering_args(args, fake_reader) fake_reader.SUPPORTS_TIME = False args, _ = parse_args(["logs", "--from", "1w"]) assert not logs.validate_filtering_args(a...
", "200"]) assert logs.validate_filtering_args(args, fake_reader) # Specify number of lines and lines to offset by args, _ = parse_args(["logs", "-l", "200", "-o", "23"]) assert logs.validate_filtering_args(args, fake_reader) # Specify a time args, _ = parse_args(["logs", "--from", "1w"]) as...
107
107
358
10
97
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_validate_filtering_args_with_invalid_inputs
test_validate_filtering_args_with_invalid_inputs
1,162
1,196
1,162
1,162
1a468df72d74f3228dd212f0b148bd2f26c0dc53
bigcode/the-stack
train
984637e5e8d4e2a5b9d3f0d2
train
function
@contextlib.contextmanager def reraise_keyboardinterrupt(): """If it's not caught, this kills pytest :'(""" try: yield except FakeKeyboardInterrupt: # pragma: no cover (error case only) raise AssertionError("library failed to catch KeyboardInterrupt")
@contextlib.contextmanager def reraise_keyboardinterrupt():
"""If it's not caught, this kills pytest :'(""" try: yield except FakeKeyboardInterrupt: # pragma: no cover (error case only) raise AssertionError("library failed to catch KeyboardInterrupt")
True except ImportError: # pragma: no cover (yelpy) scribereader_available = False class FakeKeyboardInterrupt(KeyboardInterrupt): """Raising a real KeyboardInterrupt causes pytest to, y'know, stop.""" @contextlib.contextmanager def reraise_keyboardinterrupt():
63
64
60
13
50
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
reraise_keyboardinterrupt
reraise_keyboardinterrupt
43
49
43
44
e3b25afde879df27bd4e402ec1813e4418c6840a
bigcode/the-stack
train
ee6186847dc9f92d600369d7
train
function
def test_prettify_level_less_than_or_equal_to_one_requested_levels(): level = "fake_level" requested_levels = [] assert level not in logs.prettify_level(level, requested_levels)
def test_prettify_level_less_than_or_equal_to_one_requested_levels():
level = "fake_level" requested_levels = [] assert level not in logs.prettify_level(level, requested_levels)
def test_prettify_level_more_than_one_requested_levels(): level = "fake_level" requested_levels = ["fake_requested_level", "fake_requested_level2"] assert level in logs.prettify_level(level, requested_levels) def test_prettify_level_less_than_or_equal_to_one_requested_levels():
64
64
42
15
49
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_prettify_level_less_than_or_equal_to_one_requested_levels
test_prettify_level_less_than_or_equal_to_one_requested_levels
623
626
623
623
4159c278ab1c01b04f3e3ca5e62a601f2831a15b
bigcode/the-stack
train
429a3a6aa4997c452e0bb3c3
train
function
def test_extract_utc_timestamp_from_log_line_when_missing_date(): line = "this is a fake invalid syslog message" assert not logs.extract_utc_timestamp_from_log_line(line)
def test_extract_utc_timestamp_from_log_line_when_missing_date():
line = "this is a fake invalid syslog message" assert not logs.extract_utc_timestamp_from_log_line(line)
5-07-22T17:38:46.000000") line = "%s this is a fake syslog test message" % fake_timestamp assert logs.extract_utc_timestamp_from_log_line(line) == fake_utc_timestamp def test_extract_utc_timestamp_from_log_line_when_missing_date():
64
64
39
13
50
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_extract_utc_timestamp_from_log_line_when_missing_date
test_extract_utc_timestamp_from_log_line_when_missing_date
381
383
381
381
ac7f2f2ce9d69fdfc8388610d9f3e7285fa900bc
bigcode/the-stack
train
e916ea9095ca77084c731633
train
function
def test_paasta_log_line_passes_filter_true_when_default_instance(): service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = None components = ["build", "deploy"] line = "fake_line" formatted_li...
def test_paasta_log_line_passes_filter_true_when_default_instance():
service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = None components = ["build", "deploy"] line = "fake_line" formatted_line = format_log_line( levels[0], ANY_CLUSTER, service, instan...
ANY_CLUSTER, service, instance, components[0], line ) assert ( logs.paasta_log_line_passes_filter( formatted_line, levels, service, components, clusters, instances ) is True ) def test_paasta_log_line_passes_filter_true_when_default_instance():
64
64
138
14
50
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_paasta_log_line_passes_filter_true_when_default_instance
test_paasta_log_line_passes_filter_true_when_default_instance
129
145
129
129
2949f5a810892bf50fb3b8c8a62b6ea9d689afc4
bigcode/the-stack
train
c37ab10d12af212cd41cd264
train
function
def test_paasta_log_line_passes_filter_false_when_line_not_valid_json(): service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instances = ["fake_instance"] components = ["build", "deploy"] line = "i am definitely not json" # component...
def test_paasta_log_line_passes_filter_false_when_line_not_valid_json():
service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instances = ["fake_instance"] components = ["build", "deploy"] line = "i am definitely not json" # component must be legit as well as not in the list of requested # components ...
", service, instance, components[0], line ) assert ( logs.paasta_log_line_passes_filter( formatted_line, levels, service, components, clusters, instances ) is False ) def test_paasta_log_line_passes_filter_false_when_line_not_valid_json():
64
64
129
16
48
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_paasta_log_line_passes_filter_false_when_line_not_valid_json
test_paasta_log_line_passes_filter_false_when_line_not_valid_json
230
244
230
230
4854b50b0c34623725b6073e2803a01d26ea935f
bigcode/the-stack
train
8a03eb880c44a3ea61e3f5b3
train
function
def test_paasta_log_line_passes_filter_false_when_wrong_instance(): service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "non-existant_instance" instances = ["fake_instance"] components = ["build", "deploy"] line = "fake_li...
def test_paasta_log_line_passes_filter_false_when_wrong_instance():
service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "non-existant_instance" instances = ["fake_instance"] components = ["build", "deploy"] line = "fake_line" # component must be legit as well as not in the list of requ...
US_CLUSTER", service, instance, components[0], line ) assert ( logs.paasta_log_line_passes_filter( formatted_line, levels, service, components, clusters, instances ) is False ) def test_paasta_log_line_passes_filter_false_when_wrong_instance():
64
64
165
14
50
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_paasta_log_line_passes_filter_false_when_wrong_instance
test_paasta_log_line_passes_filter_false_when_wrong_instance
209
227
209
209
0d9d8aef98c59c2b1b1c442d14a0985df1f5e4fc
bigcode/the-stack
train
b82bf5d4b750e42fd029112d
train
function
def test_generate_start_end_time_human_durations(): start_time, end_time = logs.generate_start_end_time("35m", "25m") time_delta = end_time - start_time actual_time = time_delta.total_seconds() ideal_time = 10 * 60 # See note on the test above why this is not a simple == comparison assert abs...
def test_generate_start_end_time_human_durations():
start_time, end_time = logs.generate_start_end_time("35m", "25m") time_delta = end_time - start_time actual_time = time_delta.total_seconds() ideal_time = 10 * 60 # See note on the test above why this is not a simple == comparison assert abs(actual_time - ideal_time) < 0.1
take a few milliseconds itself, doing a straight up == comparison # would not work actual_time = time_delta.total_seconds() ideal_time = 30 * 60 assert abs(actual_time - ideal_time) < 0.1 def test_generate_start_end_time_human_durations():
64
64
92
11
52
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_generate_start_end_time_human_durations
test_generate_start_end_time_human_durations
1,108
1,117
1,108
1,108
faa1648ae7338578eb530aead425666129aec64f
bigcode/the-stack
train
3a9ec1853dc4f86d7a8bc0fc
train
function
def test_paasta_log_line_passes_filter_false_when_wrong_level(): service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = [instance] components = ["build", "deploy"] line = "fake_line" formatted_...
def test_paasta_log_line_passes_filter_false_when_wrong_level():
service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = [instance] components = ["build", "deploy"] line = "fake_line" formatted_line = format_log_line( "BOGUS_LEVEL", clusters[0], servi...
ANY_CLUSTER, service, instance, components[0], line ) assert ( logs.paasta_log_line_passes_filter( formatted_line, levels, service, components, clusters, instances ) is True ) def test_paasta_log_line_passes_filter_false_when_wrong_level():
64
64
142
14
50
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_paasta_log_line_passes_filter_false_when_wrong_level
test_paasta_log_line_passes_filter_false_when_wrong_level
148
164
148
148
016e78195f295e92afb3a8ccb75c57b82e9ee640
bigcode/the-stack
train
828d63054a8854bca9c3ca0f
train
function
def test_paasta_log_line_passes_filter_false_when_wrong_cluster(): service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = [instance] components = ["build", "deploy"] line = "fake_line" # compon...
def test_paasta_log_line_passes_filter_false_when_wrong_cluster():
service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = [instance] components = ["build", "deploy"] line = "fake_line" # component must be legit as well as not in the list of requested # com...
[0], service, instance, "monitoring", line ) assert ( logs.paasta_log_line_passes_filter( formatted_line, levels, service, components, clusters, instances ) is False ) def test_paasta_log_line_passes_filter_false_when_wrong_cluster():
64
64
162
14
50
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_paasta_log_line_passes_filter_false_when_wrong_cluster
test_paasta_log_line_passes_filter_false_when_wrong_cluster
188
206
188
188
5a18325e6b6fe1bfc9d792a11cc8d8dd0c99f5fa
bigcode/the-stack
train
235e9c7eb5f38d3d432e4016
train
function
def test_marathon_log_line_passes_filter_true_when_service_name_in_string(): service = "fake_service" levels = [] components = [] clusters = [] instances = [] line = format_log_line( "fake_level", clusters, service, "fake_instance", "marathon", "fa...
def test_marathon_log_line_passes_filter_true_when_service_name_in_string():
service = "fake_service" levels = [] components = [] clusters = [] instances = [] line = format_log_line( "fake_level", clusters, service, "fake_instance", "marathon", "fake message with service name %s" % service, ) with mock.patch( ...
logs.paasta_log_line_passes_filter( formatted_line, levels, service, components, clusters, instances, start_time=start_time, end_time=end_time, ) is False ) def test_marathon_log_line_passes_filter_true_...
64
64
148
16
48
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_marathon_log_line_passes_filter_true_when_service_name_in_string
test_marathon_log_line_passes_filter_true_when_service_name_in_string
320
340
320
320
8a9048fb83d60dfeadf6833a16901174fd5ce8f1
bigcode/the-stack
train
eb82a3f667d576a4102a9a18
train
function
def test_prettify_log_line_valid_json_missing_key(): line = json.dumps( {"component": "fake_component", "oops_i_spelled_timestamp_rong": "1999-09-09"} ) levels = [] actual = logs.prettify_log_line(line, levels) assert "JSON missing keys: %s" % line in actual
def test_prettify_log_line_valid_json_missing_key():
line = json.dumps( {"component": "fake_component", "oops_i_spelled_timestamp_rong": "1999-09-09"} ) levels = [] actual = logs.prettify_log_line(line, levels) assert "JSON missing keys: %s" % line in actual
_level(level, requested_levels) def test_prettify_log_line_invalid_json(): line = "i am not json" levels = [] assert logs.prettify_log_line(line, levels) == "Invalid JSON: %s" % line def test_prettify_log_line_valid_json_missing_key():
64
64
77
12
51
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_prettify_log_line_valid_json_missing_key
test_prettify_log_line_valid_json_missing_key
635
641
635
635
3d6716e2438ea5aaad03e7968034233db8c2f9a7
bigcode/the-stack
train
e8f62af9ba3066e7e11b8b25
train
class
class FakeKeyboardInterrupt(KeyboardInterrupt): """Raising a real KeyboardInterrupt causes pytest to, y'know, stop."""
class FakeKeyboardInterrupt(KeyboardInterrupt):
"""Raising a real KeyboardInterrupt causes pytest to, y'know, stop."""
# pragma: no cover (yelpy) from scribereader.scribereader import StreamTailerSetupError scribereader_available = True except ImportError: # pragma: no cover (yelpy) scribereader_available = False class FakeKeyboardInterrupt(KeyboardInterrupt):
64
64
26
8
55
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
FakeKeyboardInterrupt
FakeKeyboardInterrupt
39
40
39
39
69911e61e1e65b9770576307ec63a0bffb4cafac
bigcode/the-stack
train
502dc375b799219588084cf7
train
function
def test_check_timestamp_in_range_false(): timestamp = datetime.datetime.utcnow() start_time, end_time = logs.generate_start_end_time("10m", "5m") assert logs.check_timestamp_in_range(timestamp, start_time, end_time) is False
def test_check_timestamp_in_range_false():
timestamp = datetime.datetime.utcnow() start_time, end_time = logs.generate_start_end_time("10m", "5m") assert logs.check_timestamp_in_range(timestamp, start_time, end_time) is False
1 def test_check_timestamp_in_range_with_none_arguments(): assert ( logs.check_timestamp_in_range(timestamp=None, start_time=None, end_time=None) is True ) assert logs.check_timestamp_in_range(datetime.datetime.utcnow(), None, None) is True def test_check_timestamp_in_range_false():
64
64
53
8
55
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_check_timestamp_in_range_false
test_check_timestamp_in_range_false
75
79
75
75
8306d8e5a68141750172aa0918705cd2d7fc4250
bigcode/the-stack
train
9a7cafcc723dfad4a0146115
train
function
def test_paasta_log_line_passes_filter_true_when_default_cluster(): service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = [instance] components = ["build", "deploy"] line = "fake_line" formatt...
def test_paasta_log_line_passes_filter_true_when_default_cluster():
service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = [instance] components = ["build", "deploy"] line = "fake_line" formatted_line = format_log_line( levels[0], ANY_CLUSTER, service, ...
[0], service, instance, components[0], line ) assert ( logs.paasta_log_line_passes_filter( formatted_line, levels, service, components, clusters, instances ) is True ) def test_paasta_log_line_passes_filter_true_when_default_cluster():
64
64
139
14
50
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_paasta_log_line_passes_filter_true_when_default_cluster
test_paasta_log_line_passes_filter_true_when_default_cluster
110
126
110
110
1dac7b815f0fd2eb2d76924fa4f3ce911986e241
bigcode/the-stack
train
d8781b683f386831046c3cdb
train
function
def test_paasta_log_line_passes_filter_false_when_wrong_component(): service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = [instance] components = ["build", "deploy"] line = "fake_line" # comp...
def test_paasta_log_line_passes_filter_false_when_wrong_component():
service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = [instance] components = ["build", "deploy"] line = "fake_line" # component must be legit as well as not in the list of requested # com...
[0], service, instance, components[0], line ) assert ( logs.paasta_log_line_passes_filter( formatted_line, levels, service, components, clusters, instances ) is False ) def test_paasta_log_line_passes_filter_false_when_wrong_component():
64
64
160
14
50
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_paasta_log_line_passes_filter_false_when_wrong_component
test_paasta_log_line_passes_filter_false_when_wrong_component
167
185
167
167
be4f06b0b1fcf3bec596d1803851a16e5ed594b0
bigcode/the-stack
train
b2cd17d295734360ed82a487
train
function
def test_check_timestamp_in_range_with_none_arguments(): assert ( logs.check_timestamp_in_range(timestamp=None, start_time=None, end_time=None) is True ) assert logs.check_timestamp_in_range(datetime.datetime.utcnow(), None, None) is True
def test_check_timestamp_in_range_with_none_arguments():
assert ( logs.check_timestamp_in_range(timestamp=None, start_time=None, end_time=None) is True ) assert logs.check_timestamp_in_range(datetime.datetime.utcnow(), None, None) is True
", autospec=True): scribe_log_reader = logs.ScribeLogReader(cluster_map={}) with raises(SystemExit) as sys_exit: scribe_log_reader.cluster_to_scribe_env("dne") assert sys_exit.value.code == 1 def test_check_timestamp_in_range_with_none_arguments():
64
64
54
10
53
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_check_timestamp_in_range_with_none_arguments
test_check_timestamp_in_range_with_none_arguments
67
72
67
67
a74b8279894582d982a19de3f2d399d61c332574
bigcode/the-stack
train
1c2d92bf2ed056042a368ee2
train
function
def test_determine_scribereader_additional_envs(): cluster = "fake_cluster" components = ["fake_component"] with mock.patch( "paasta_tools.cli.cmds.logs.scribereader", autospec=True ), mock.patch( "paasta_tools.cli.cmds.logs.LOG_COMPONENTS", spec_set=dict, autospec=None ) as mock_LOG...
def test_determine_scribereader_additional_envs():
cluster = "fake_cluster" components = ["fake_component"] with mock.patch( "paasta_tools.cli.cmds.logs.scribereader", autospec=True ), mock.patch( "paasta_tools.cli.cmds.logs.LOG_COMPONENTS", spec_set=dict, autospec=None ) as mock_LOG_COMPONENTS: cluster_map = {cluster: "fake_...
fake_scribe_env"} actual = logs.ScribeLogReader( cluster_map=cluster_map ).determine_scribereader_envs(components, cluster) assert actual == {"devc", "fake_scribe_env"} def test_determine_scribereader_additional_envs():
63
64
192
13
50
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_determine_scribereader_additional_envs
test_determine_scribereader_additional_envs
1,048
1,065
1,048
1,048
71b0a75808061b637832dd6dee8727c507b4b7be
bigcode/the-stack
train
c2c6de03885ce58fd255b2d8
train
function
def test_prettify_log_line_valid_json_requested_level_is_only_event(): requested_levels = ["fake_requested_level1"] parsed_line = { "message": "fake_message", "component": "fake_component", "level": "event", "cluster": "fake_cluster", "instance": "fake_instance", ...
def test_prettify_log_line_valid_json_requested_level_is_only_event():
requested_levels = ["fake_requested_level1"] parsed_line = { "message": "fake_message", "component": "fake_component", "level": "event", "cluster": "fake_cluster", "instance": "fake_instance", "timestamp": "2015-03-12T21:20:04.602002", } line = json.dumps(...
assert parsed_line["component"] in actual assert parsed_line["cluster"] in actual assert parsed_line["instance"] in actual assert parsed_line["level"] in actual assert parsed_line["message"] in actual def test_prettify_log_line_valid_json_requested_level_is_only_event():
64
64
125
15
48
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_prettify_log_line_valid_json_requested_level_is_only_event
test_prettify_log_line_valid_json_requested_level_is_only_event
666
679
666
666
ccf671306e136085b388f2c98f785fd37cfa7d96
bigcode/the-stack
train
52974b659c909331ab0e6bbf
train
function
def test_tail_paasta_logs_empty_clusters(): service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["deploy", "monitoring"] clusters = [] instances = ["fake_instance"] with mock.patch( "paasta_tools.cli.cmds.logs.ScribeLogReader.determine_scribereader_envs", ...
def test_tail_paasta_logs_empty_clusters():
service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["deploy", "monitoring"] clusters = [] instances = ["fake_instance"] with mock.patch( "paasta_tools.cli.cmds.logs.ScribeLogReader.determine_scribereader_envs", autospec=True, ) as determine_scribere...
cribe_log_reader.tail_logs(service, levels, components, clusters, instances) # is_alive() should be called on all the values we painstakingly provided above. assert fake_process.is_alive.call_count == len(is_alive_responses) # We only terminate the first thread, which is still alive. We don't ...
98
98
328
9
88
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_tail_paasta_logs_empty_clusters
test_tail_paasta_logs_empty_clusters
933
963
933
933
3b4fa135f171b876fcb1446045417da2b857382a
bigcode/the-stack
train
24a00299d55cec4c423b19be
train
function
def test_generate_start_end_time(): start_time, end_time = logs.generate_start_end_time() # Default for no args, test that there's a 30 minute difference time_delta = end_time - start_time # Do a loose comparison to make this test less time sensitive. # On slower systems, doing a datetime.datetime...
def test_generate_start_end_time():
start_time, end_time = logs.generate_start_end_time() # Default for no args, test that there's a 30 minute difference time_delta = end_time - start_time # Do a loose comparison to make this test less time sensitive. # On slower systems, doing a datetime.datetime.utcnow() might # take a few mil...
.patch( "paasta_tools.cli.cmds.logs.scribereader", autospec=True ): mock_load_system_paasta_config.return_value = mock_system_paasta_config actual = logs.get_log_reader() assert isinstance(actual, logs.ScribeLogReader) def test_generate_start_end_time():
64
64
129
7
57
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_generate_start_end_time
test_generate_start_end_time
1,092
1,105
1,092
1,092
25678e15e18cdf1a380e694b0a36bb1ef80f5152
bigcode/the-stack
train
48fd07597cf40fcb6636b972
train
function
def test_tail_paasta_logs_empty_instances(): service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["deploy", "monitoring"] clusters = ["fake_cluster"] instances = [] with mock.patch( "paasta_tools.cli.cmds.logs.ScribeLogReader.determine_scribereader_envs", ...
def test_tail_paasta_logs_empty_instances():
service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["deploy", "monitoring"] clusters = ["fake_cluster"] instances = [] with mock.patch( "paasta_tools.cli.cmds.logs.ScribeLogReader.determine_scribereader_envs", autospec=True, ) as determine_scriberea...
_scribereader_envs_patch.return_value = [] fake_queue = mock.MagicMock(spec_set=Queue()) fake_queue.get.side_effect = Empty queue_patch.return_value = fake_queue logs.ScribeLogReader(cluster_map={}).tail_logs( service, levels, components, clusters, instances ) ...
98
98
328
9
88
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_tail_paasta_logs_empty_instances
test_tail_paasta_logs_empty_instances
966
996
966
966
1f9b6e6d541976a8870c9afdaeedaf8629cdc424
bigcode/the-stack
train
4cf0fac420779fd68b66c850
train
function
def test_cluster_to_scribe_env_good(): with mock.patch("paasta_tools.cli.cmds.logs.scribereader", autospec=True): scribe_log_reader = logs.ScribeLogReader(cluster_map={"mesosstage": "env1"}) actual = scribe_log_reader.cluster_to_scribe_env("mesosstage") assert actual == "env1"
def test_cluster_to_scribe_env_good():
with mock.patch("paasta_tools.cli.cmds.logs.scribereader", autospec=True): scribe_log_reader = logs.ScribeLogReader(cluster_map={"mesosstage": "env1"}) actual = scribe_log_reader.cluster_to_scribe_env("mesosstage") assert actual == "env1"
def reraise_keyboardinterrupt(): """If it's not caught, this kills pytest :'(""" try: yield except FakeKeyboardInterrupt: # pragma: no cover (error case only) raise AssertionError("library failed to catch KeyboardInterrupt") def test_cluster_to_scribe_env_good():
64
64
77
9
55
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_cluster_to_scribe_env_good
test_cluster_to_scribe_env_good
52
56
52
52
fa132cc97e9ca3615a9be719c4342d65a1d3d910
bigcode/the-stack
train
0836cc07b23c70a9f6903083
train
function
def test_generate_start_end_time_invalid_to(): with pytest.raises(ValueError): logs.generate_start_end_time("2016-06-06T20:25:49+00:00", "invalid")
def test_generate_start_end_time_invalid_to():
with pytest.raises(ValueError): logs.generate_start_end_time("2016-06-06T20:25:49+00:00", "invalid")
20:25:49+00:00" ) def test_generate_start_end_time_invalid_from(): with pytest.raises(ValueError): logs.generate_start_end_time("invalid", "2016-06-06T20:25:49+00:00") def test_generate_start_end_time_invalid_to():
64
64
43
9
55
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_generate_start_end_time_invalid_to
test_generate_start_end_time_invalid_to
1,133
1,135
1,133
1,133
e314d0c2c775ccc2eeeb14e6378b889d10b851db
bigcode/the-stack
train
6c7fdf18e94d74ccfef78bbd
train
function
def test_cluster_to_scribe_env_bad(): with mock.patch("paasta_tools.cli.cmds.logs.scribereader", autospec=True): scribe_log_reader = logs.ScribeLogReader(cluster_map={}) with raises(SystemExit) as sys_exit: scribe_log_reader.cluster_to_scribe_env("dne") assert sys_exit.value.code...
def test_cluster_to_scribe_env_bad():
with mock.patch("paasta_tools.cli.cmds.logs.scribereader", autospec=True): scribe_log_reader = logs.ScribeLogReader(cluster_map={}) with raises(SystemExit) as sys_exit: scribe_log_reader.cluster_to_scribe_env("dne") assert sys_exit.value.code == 1
cribereader", autospec=True): scribe_log_reader = logs.ScribeLogReader(cluster_map={"mesosstage": "env1"}) actual = scribe_log_reader.cluster_to_scribe_env("mesosstage") assert actual == "env1" def test_cluster_to_scribe_env_bad():
64
64
79
9
55
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_cluster_to_scribe_env_bad
test_cluster_to_scribe_env_bad
59
64
59
59
1f6eb2927b0e6c6447ad113829de3f2212de7f54
bigcode/the-stack
train
b709cfb19ff17fb5fbd3e6b9
train
function
def test_generate_start_end_time_invalid(): # Try giving a start time that's later than the end time with pytest.raises(ValueError): logs.generate_start_end_time( "2016-06-06T20:26:49+00:00", "2016-06-06T20:25:49+00:00" )
def test_generate_start_end_time_invalid(): # Try giving a start time that's later than the end time
with pytest.raises(ValueError): logs.generate_start_end_time( "2016-06-06T20:26:49+00:00", "2016-06-06T20:25:49+00:00" )
ideal_time = 10 * 60 # See note on the test above why this is not a simple == comparison assert abs(actual_time - ideal_time) < 0.1 def test_generate_start_end_time_invalid(): # Try giving a start time that's later than the end time
64
64
75
22
41
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_generate_start_end_time_invalid
test_generate_start_end_time_invalid
1,120
1,125
1,120
1,121
44db103547bb3aa6317016918d4f5b85d3cc83f1
bigcode/the-stack
train
4b65ed50e4b7afc856090507
train
function
def test_paasta_log_line_passes_filter_true(): service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = [instance] components = ["build", "deploy"] line = "fake_line" formatted_line = format_log_...
def test_paasta_log_line_passes_filter_true():
service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = [instance] components = ["build", "deploy"] line = "fake_line" formatted_line = format_log_line( levels[0], clusters[0], service, ...
40:03+00:00") end_time = isodate.parse_datetime("2016-06-07T23:50:03+00:00") assert logs.check_timestamp_in_range(timestamp, start_time, end_time) is True def test_paasta_log_line_passes_filter_true():
64
64
137
11
52
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_paasta_log_line_passes_filter_true
test_paasta_log_line_passes_filter_true
91
107
91
91
a84e777527c683fdffe16273f4088323610d6646
bigcode/the-stack
train
7030a38774db70b640d7fadf
train
function
def test_scribereader_print_last_n_logs(): service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instances = ["main"] components = ["build", "deploy", "monitoring", "marathon", "stdout", "stderr"] with mock.patch( "paasta_tools.cl...
def test_scribereader_print_last_n_logs():
service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instances = ["main"] components = ["build", "deploy", "monitoring", "marathon", "stdout", "stderr"] with mock.patch( "paasta_tools.cli.cmds.logs.scribereader", autospec=True ...
ereader_envs_patch, mock.patch( "paasta_tools.cli.cmds.logs.scribereader", autospec=True ): envs = ["env1", "env2"] determine_scribereader_envs_patch.return_value = envs logs.ScribeLogReader(cluster_map={}).run_code_over_scribe_envs( clusters, components, callback ...
125
125
418
11
113
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_scribereader_print_last_n_logs
test_scribereader_print_last_n_logs
705
745
705
705
f754f3c854ed294087950e0147e6e0c096bc65c3
bigcode/the-stack
train
8bfff1a144c707138a033f72
train
function
def test_parse_marathon_log_line_fail(): assert "" == logs.parse_marathon_log_line("fake timestamp", None, None)
def test_parse_marathon_log_line_fail():
assert "" == logs.parse_marathon_log_line("fake timestamp", None, None)
_timestamp_from_log_line(line) def test_extract_utc_timestamp_from_log_line_when_invalid_date_format(): line = "Jul 22 10:39:08 this is a fake invalid syslog message" assert not logs.extract_utc_timestamp_from_log_line(line) def test_parse_marathon_log_line_fail():
64
64
27
9
55
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_parse_marathon_log_line_fail
test_parse_marathon_log_line_fail
391
392
391
391
563b6866697f1896f8cc837d1168ba30fa280713
bigcode/the-stack
train
8a1ac8a48aa6439570bd980a
train
function
def test_tail_paasta_logs_marathon(): service = "fake_service" clusters = ["fake_cluster"] instances = ["fake_instance"] levels = ["fake_level1", "fake_level2"] components = ["marathon"] with mock.patch( "paasta_tools.cli.cmds.logs.ScribeLogReader.determine_scribereader_envs", au...
def test_tail_paasta_logs_marathon():
service = "fake_service" clusters = ["fake_cluster"] instances = ["fake_instance"] levels = ["fake_level1", "fake_level2"] components = ["marathon"] with mock.patch( "paasta_tools.cli.cmds.logs.ScribeLogReader.determine_scribereader_envs", autospec=True, ) as determine_scribe...
asta_tools.cli.cmds.logs.scribereader", autospec=True ): determine_scribereader_envs_patch.return_value = [] fake_queue = mock.MagicMock(spec_set=Queue()) fake_queue.get.side_effect = Empty queue_patch.return_value = fake_queue logs.ScribeLogReader(cluster_map={}).tail_logs( ...
117
117
392
9
107
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_tail_paasta_logs_marathon
test_tail_paasta_logs_marathon
999
1,034
999
999
bbfd5026112149b7e3e8cb2a9a99d8af40000037
bigcode/the-stack
train
444008f99a0034a217f68cfe
train
function
def test_tail_paasta_logs_aliveness_check(): service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["deploy", "monitoring"] clusters = ["fake_cluster1", "fake_cluster2"] instances = ["fake_instance1", "fake_instance2"] with mock.patch( "paasta_tools.cli.cmds.logs....
def test_tail_paasta_logs_aliveness_check():
service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["deploy", "monitoring"] clusters = ["fake_cluster1", "fake_cluster2"] instances = ["fake_instance1", "fake_instance2"] with mock.patch( "paasta_tools.cli.cmds.logs.ScribeLogReader.determine_scribereader_envs",...
s_patch.return_value = ["env1", "env2"] fake_queue = mock.MagicMock(spec_set=Queue()) fake_queue.get.side_effect = Empty queue_patch.return_value = fake_queue fake_process = mock.MagicMock() fake_process.is_alive.side_effect = FakeKeyboardInterrupt process_patch.return_va...
168
168
563
10
158
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_tail_paasta_logs_aliveness_check
test_tail_paasta_logs_aliveness_check
879
930
879
879
2f35a84227807fa41defff84cdcf58ba3f81fb12
bigcode/the-stack
train
20f15b45df0eda60a530bebe
train
function
def test_scribereader_run_code_over_scribe_envs(): clusters = ["fake_cluster1", "fake_cluster2"] components = ["build", "deploy", "monitoring", "marathon", "stdout", "stderr"] callback = mock.MagicMock() with mock.patch( "paasta_tools.cli.cmds.logs.ScribeLogReader.determine_scribereader_envs",...
def test_scribereader_run_code_over_scribe_envs():
clusters = ["fake_cluster1", "fake_cluster2"] components = ["build", "deploy", "monitoring", "marathon", "stdout", "stderr"] callback = mock.MagicMock() with mock.patch( "paasta_tools.cli.cmds.logs.ScribeLogReader.determine_scribereader_envs", autospec=True, ) as determine_scribere...
5-03-12T21:20:04.602002", } line = json.dumps(parsed_line) actual = logs.prettify_log_line(line, requested_levels) assert parsed_line["level"] not in actual def test_scribereader_run_code_over_scribe_envs():
64
64
210
14
49
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_scribereader_run_code_over_scribe_envs
test_scribereader_run_code_over_scribe_envs
682
702
682
682
1b2a62b1e026a35690c3ad151c47698aa436bf83
bigcode/the-stack
train
fc24bf692a1aa6e07388652d
train
function
def test_prettify_timestamp(): timestamp = "2015-03-12T21:20:04.602002" actual = logs.prettify_timestamp(timestamp) # kwa and I tried to get python to recognize a hardcoded timezone # in TZ, even using tzset(), but it ignored us. So we're punting. assert "2015-03-12 " in actual assert ":20:04" i...
def test_prettify_timestamp():
timestamp = "2015-03-12T21:20:04.602002" actual = logs.prettify_timestamp(timestamp) # kwa and I tried to get python to recognize a hardcoded timezone # in TZ, even using tzset(), but it ignored us. So we're punting. assert "2015-03-12 " in actual assert ":20:04" in actual
env, stream_name, service, levels, components, clusters, queue, filter_fn, ) mock_log.error.assert_any_call( "Failed to setup stream tailing for %s in fake_env"...
64
64
96
7
57
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_prettify_timestamp
test_prettify_timestamp
594
600
594
594
cb5bfa926e0c0d373e5f9610ae9328011ca73fea
bigcode/the-stack
train
ed7bd703ac0edfa1ac6602f7
train
function
def test_parse_marathon_log_line_ok(): fake_timestamp = "2015-07-22T10:38:46-07:00" fake_utc_timestamp = "2015-07-22T17:38:46.000000" fake_service = "fake_service" line = "%s this is a fake syslog test message" % fake_timestamp clusters = ["fake_cluster"] expected = json.dumps( { ...
def test_parse_marathon_log_line_ok():
fake_timestamp = "2015-07-22T10:38:46-07:00" fake_utc_timestamp = "2015-07-22T17:38:46.000000" fake_service = "fake_service" line = "%s this is a fake syslog test message" % fake_timestamp clusters = ["fake_cluster"] expected = json.dumps( { "timestamp": fake_utc_timestamp, ...
10:39:08 this is a fake invalid syslog message" assert not logs.extract_utc_timestamp_from_log_line(line) def test_parse_marathon_log_line_fail(): assert "" == logs.parse_marathon_log_line("fake timestamp", None, None) def test_parse_marathon_log_line_ok():
64
64
176
9
55
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_parse_marathon_log_line_ok
test_parse_marathon_log_line_ok
395
415
395
395
184b4513d3df60f5b23d93b2a0b1741d36251aa3
bigcode/the-stack
train
8806fdb6a3093032d202cde2
train
function
def test_get_log_reader(): mock_system_paasta_config = mock.Mock( autospec="paasta_tools.utils.SystemPaastaConfig" ) mock_system_paasta_config.get_log_reader.return_value = { "driver": "scribereader", "options": {"cluster_map": {}}, } with mock.patch( "paasta_tools.cl...
def test_get_log_reader():
mock_system_paasta_config = mock.Mock( autospec="paasta_tools.utils.SystemPaastaConfig" ) mock_system_paasta_config.get_log_reader.return_value = { "driver": "scribereader", "options": {"cluster_map": {}}, } with mock.patch( "paasta_tools.cli.cmds.logs.load_system_paa...
ermine_scribereader_envs(components, cluster) assert "fake_scribe_env" in actual and "fake_scribe_env2" in actual def test_prefix(): actual = logs.prefix("TEST STRING", "deploy") assert "TEST STRING" in actual def test_get_log_reader():
64
64
157
6
57
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_get_log_reader
test_get_log_reader
1,073
1,089
1,073
1,073
b4149689efaf773ba661f99902ca0e8fb95e6138
bigcode/the-stack
train
2c0c66ab908cc46e3f431620
train
function
def test_extract_utc_timestamp_from_log_line_ok(): fake_timestamp = "2015-07-22T10:38:46-07:00" fake_utc_timestamp = isodate.parse_datetime("2015-07-22T17:38:46.000000") line = "%s this is a fake syslog test message" % fake_timestamp assert logs.extract_utc_timestamp_from_log_line(line) == fake_utc_tim...
def test_extract_utc_timestamp_from_log_line_ok():
fake_timestamp = "2015-07-22T10:38:46-07:00" fake_utc_timestamp = isodate.parse_datetime("2015-07-22T17:38:46.000000") line = "%s this is a fake syslog test message" % fake_timestamp assert logs.extract_utc_timestamp_from_log_line(line) == fake_utc_timestamp
, components, clusters, instances ) def test_marathon_log_line_passes_filter_fails_invalid_json(): assert not logs.marathon_log_line_passes_filter( "{ abcd }", None, None, None, None, None ) def test_extract_utc_timestamp_from_log_line_ok():
64
64
97
11
53
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_extract_utc_timestamp_from_log_line_ok
test_extract_utc_timestamp_from_log_line_ok
373
378
373
373
6bcab9dd0f201fbee3a218710f5ce3187bef410d
bigcode/the-stack
train
877b17ad87af6e8563d6dbb6
train
function
def test_prettify_level_more_than_one_requested_levels(): level = "fake_level" requested_levels = ["fake_requested_level", "fake_requested_level2"] assert level in logs.prettify_level(level, requested_levels)
def test_prettify_level_more_than_one_requested_levels():
level = "fake_level" requested_levels = ["fake_requested_level", "fake_requested_level2"] assert level in logs.prettify_level(level, requested_levels)
ABLE COMPONENT" not in actual def test_prettify_component_invalid(): component = "non-existent component" actual = logs.prettify_component(component) assert component in actual assert "UNPRETTIFIABLE COMPONENT" in actual def test_prettify_level_more_than_one_requested_levels():
64
64
48
12
51
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_prettify_level_more_than_one_requested_levels
test_prettify_level_more_than_one_requested_levels
617
620
617
617
8453c135b137c2f38da04087be8302eb095f74d0
bigcode/the-stack
train
74776ed8e8904028bedbbd6a
train
function
def test_prettify_log_line_invalid_json(): line = "i am not json" levels = [] assert logs.prettify_log_line(line, levels) == "Invalid JSON: %s" % line
def test_prettify_log_line_invalid_json():
line = "i am not json" levels = [] assert logs.prettify_log_line(line, levels) == "Invalid JSON: %s" % line
level in logs.prettify_level(level, requested_levels) def test_prettify_level_less_than_or_equal_to_one_requested_levels(): level = "fake_level" requested_levels = [] assert level not in logs.prettify_level(level, requested_levels) def test_prettify_log_line_invalid_json():
64
64
46
10
54
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_prettify_log_line_invalid_json
test_prettify_log_line_invalid_json
629
632
629
629
22a06235cb790baa117390980c8a76511a924928
bigcode/the-stack
train
7d07dec073374e3ed69f09d1
train
function
def test_pick_default_log_mode(): with mock.patch( "paasta_tools.cli.cmds.logs.LogReader.tail_logs", autospec=True ) as tail_logs: args, _ = parse_args(["logs"]) fake_reader = logs.LogReader() fake_reader.SUPPORTS_TAILING = True logs.pick_default_log_mode( a...
def test_pick_default_log_mode():
with mock.patch( "paasta_tools.cli.cmds.logs.LogReader.tail_logs", autospec=True ) as tail_logs: args, _ = parse_args(["logs"]) fake_reader = logs.LogReader() fake_reader.SUPPORTS_TAILING = True logs.pick_default_log_mode( args, fake_reader, ...
l", "200", "--tail"]) assert not logs.validate_filtering_args(args, fake_reader) # Can't tail and specify time at the same time args, _ = parse_args(["logs", "--tail", "--from", "1w"]) assert not logs.validate_filtering_args(args, fake_reader) # Can't use both time and lines at the same time a...
122
122
407
7
115
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_pick_default_log_mode
test_pick_default_log_mode
1,199
1,264
1,199
1,199
8ff81d6c74f5211f52ad8855d642cd10759085a3
bigcode/the-stack
train
bd2532064e2e3b1f3ff32e07
train
function
def test_prettify_log_line_valid_json(): parsed_line = { "message": "fake_message", "component": "fake_component", "level": "fake_level", "cluster": "fake_cluster", "instance": "fake_instance", "timestamp": "2015-03-12T21:20:04.602002", } requested_levels = ["...
def test_prettify_log_line_valid_json():
parsed_line = { "message": "fake_message", "component": "fake_component", "level": "fake_level", "cluster": "fake_cluster", "instance": "fake_instance", "timestamp": "2015-03-12T21:20:04.602002", } requested_levels = ["fake_requested_level1", "fake_requested_l...
fake_component", "oops_i_spelled_timestamp_rong": "1999-09-09"} ) levels = [] actual = logs.prettify_log_line(line, levels) assert "JSON missing keys: %s" % line in actual def test_prettify_log_line_valid_json():
64
64
187
10
53
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_prettify_log_line_valid_json
test_prettify_log_line_valid_json
644
663
644
644
f261b93da022ee8fe296f95e7d68e9d0cc7323de
bigcode/the-stack
train
2f0736f3f3a31ff5d4a3453c
train
function
@pytest.mark.skipif( not scribereader_available, reason="scribereader not available" ) # pragma: no cover (yelpy) def test_scribe_tail_handles_StreamTailerSetupError(): env = "fake_env" stream_name = "fake_stream" service = "fake_service" levels = ["fake_level1"] components = ["build"] clus...
@pytest.mark.skipif( not scribereader_available, reason="scribereader not available" ) # pragma: no cover (yelpy) def test_scribe_tail_handles_StreamTailerSetupError():
env = "fake_env" stream_name = "fake_stream" service = "fake_service" levels = ["fake_level1"] components = ["build"] clusters = ["fake_cluster1"] queue = Queue() filter_fn = mock.Mock(return_value=True) with mock.patch( "paasta_tools.cli.cmds.logs.scribereader", autospec=Tr...
, clusters, queue, filter_fn, ) # If we made it here, KeyboardInterrupt was not raised and this test # was successful. @pytest.mark.skipif( not scribereader_available, reason="scribereader not available" ) # pragma: no cover (yelpy) def te...
78
78
263
43
35
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_scribe_tail_handles_StreamTailerSetupError
test_scribe_tail_handles_StreamTailerSetupError
557
591
557
560
e20165e7a0cf5dadb1b399eb260330bf40e8dd29
bigcode/the-stack
train
796d82237e1f2531ce9a8fc9
train
function
def test_paasta_log_line_passes_filter_true_when_valid_time(): service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = [instance] components = ["build", "deploy"] line = "fake_line" formatted_li...
def test_paasta_log_line_passes_filter_true_when_valid_time():
service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = [instance] components = ["build", "deploy"] line = "fake_line" formatted_line = format_log_line( levels[0], clusters[0], ...
json" # component must be legit as well as not in the list of requested # components assert ( logs.paasta_log_line_passes_filter( line, levels, service, components, clusters, instances ) is False ) def test_paasta_log_line_passes_filter_true_when_valid_time():
70
70
236
14
56
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_paasta_log_line_passes_filter_true_when_valid_time
test_paasta_log_line_passes_filter_true_when_valid_time
247
280
247
247
90fb8bbbdc6c0035950d5dfced404de21bc72492
bigcode/the-stack
train
ff797fbae28f77843a6f7be7
train
function
def test_paasta_log_line_passes_filter_false_when_invalid_time(): service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = [instance] components = ["build", "deploy"] line = "fake_line" formatted...
def test_paasta_log_line_passes_filter_false_when_invalid_time():
service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" instances = [instance] components = ["build", "deploy"] line = "fake_line" formatted_line = format_log_line( levels[0], clusters[0], ...
( logs.paasta_log_line_passes_filter( formatted_line, levels, service, components, clusters, instances, start_time=start_time, end_time=end_time, ) is True ) def test_paasta_log_line_passes_filte...
64
64
202
14
50
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_paasta_log_line_passes_filter_false_when_invalid_time
test_paasta_log_line_passes_filter_false_when_invalid_time
283
317
283
283
6c8e6c087ad452aaee112488a83da308295c5992
bigcode/the-stack
train
85ff31454fddac16a72a422d
train
function
def test_generate_start_end_time_invalid_from(): with pytest.raises(ValueError): logs.generate_start_end_time("invalid", "2016-06-06T20:25:49+00:00")
def test_generate_start_end_time_invalid_from():
with pytest.raises(ValueError): logs.generate_start_end_time("invalid", "2016-06-06T20:25:49+00:00")
time with pytest.raises(ValueError): logs.generate_start_end_time( "2016-06-06T20:26:49+00:00", "2016-06-06T20:25:49+00:00" ) def test_generate_start_end_time_invalid_from():
64
64
43
9
55
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_generate_start_end_time_invalid_from
test_generate_start_end_time_invalid_from
1,128
1,130
1,128
1,128
dc46dc8e4a52bbe009a345d40dddbf0efac645f1
bigcode/the-stack
train
122f21dfe33d4275ff61b53a
train
function
def test_scribereader_print_logs_by_time(): service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instances = ["main"] components = ["build", "deploy", "monitoring", "marathon", "stdout", "stderr"] with mock.patch( "paasta_tools.c...
def test_scribereader_print_logs_by_time():
service = "fake_service" levels = ["fake_level1", "fake_level2"] clusters = ["fake_cluster1", "fake_cluster2"] instances = ["main"] components = ["build", "deploy", "monitoring", "marathon", "stdout", "stderr"] with mock.patch( "paasta_tools.cli.cmds.logs.scribereader", autospec=True ...
, components, clusters, instances, raw_mode=False ) # one call per component per environment except marathon which runs 1/env/cluster # Defaults: # env1, env2 = 2 # marathon: # env1: cluster1 cluster2 = 2 # env2: cluster1 cluster2 = 2 ...
144
144
481
11
132
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_scribereader_print_logs_by_time
test_scribereader_print_logs_by_time
748
803
748
748
d2a4e0e77af4fae39c7e133aee91e72e363a7624
bigcode/the-stack
train
1676b49a427135f366c6d10b
train
function
def test_determine_scribereader_envs(): cluster = "fake_cluster" components = ["build", "monitoring"] with mock.patch("paasta_tools.cli.cmds.logs.scribereader", autospec=True): cluster_map = {cluster: "fake_scribe_env"} actual = logs.ScribeLogReader( cluster_map=cluster_map ...
def test_determine_scribereader_envs():
cluster = "fake_cluster" components = ["build", "monitoring"] with mock.patch("paasta_tools.cli.cmds.logs.scribereader", autospec=True): cluster_map = {cluster: "fake_scribe_env"} actual = logs.ScribeLogReader( cluster_map=cluster_map ).determine_scribereader_envs(compone...
queue_patch.return_value = fake_queue logs.ScribeLogReader(cluster_map={"env1": "env1"}).tail_logs( service, levels, components, clusters, instances ) assert process_patch.call_count == 1 def test_determine_scribereader_envs():
64
64
107
11
52
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_determine_scribereader_envs
test_determine_scribereader_envs
1,037
1,045
1,037
1,037
502acb43591eb1b60fb90196cf1bd05b901f2f60
bigcode/the-stack
train
1451204af3d147cc417a13f9
train
function
def test_check_timestamp_in_range_true(): timestamp = isodate.parse_datetime("2016-06-07T23:46:03+00:00") start_time = isodate.parse_datetime("2016-06-07T23:40:03+00:00") end_time = isodate.parse_datetime("2016-06-07T23:50:03+00:00") assert logs.check_timestamp_in_range(timestamp, start_time, end_time...
def test_check_timestamp_in_range_true():
timestamp = isodate.parse_datetime("2016-06-07T23:46:03+00:00") start_time = isodate.parse_datetime("2016-06-07T23:40:03+00:00") end_time = isodate.parse_datetime("2016-06-07T23:50:03+00:00") assert logs.check_timestamp_in_range(timestamp, start_time, end_time) is True
is True def test_check_timestamp_in_range_false(): timestamp = datetime.datetime.utcnow() start_time, end_time = logs.generate_start_end_time("10m", "5m") assert logs.check_timestamp_in_range(timestamp, start_time, end_time) is False def test_check_timestamp_in_range_true():
64
64
106
8
55
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_check_timestamp_in_range_true
test_check_timestamp_in_range_true
82
88
82
82
28b60aa4aa9d6c471699be6c7bfaa2d6364447be
bigcode/the-stack
train
1d2f256c7cc7e7cec676f282
train
function
def test_extract_utc_timestamp_from_log_line_when_invalid_date_format(): line = "Jul 22 10:39:08 this is a fake invalid syslog message" assert not logs.extract_utc_timestamp_from_log_line(line)
def test_extract_utc_timestamp_from_log_line_when_invalid_date_format():
line = "Jul 22 10:39:08 this is a fake invalid syslog message" assert not logs.extract_utc_timestamp_from_log_line(line)
_from_log_line(line) == fake_utc_timestamp def test_extract_utc_timestamp_from_log_line_when_missing_date(): line = "this is a fake invalid syslog message" assert not logs.extract_utc_timestamp_from_log_line(line) def test_extract_utc_timestamp_from_log_line_when_invalid_date_format():
64
64
49
14
50
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_extract_utc_timestamp_from_log_line_when_invalid_date_format
test_extract_utc_timestamp_from_log_line_when_invalid_date_format
386
388
386
386
08488f71475a56b75e2614b5e7bdbd155181dd6a
bigcode/the-stack
train
a84eb29e45fdfd13f5da5806
train
function
def test_validate_filtering_args_with_valid_inputs(): fake_reader = logs.LogReader() fake_reader.SUPPORTS_TAILING = True fake_reader.SUPPORTS_LINE_COUNT = True fake_reader.SUPPORTS_TIME = True fake_reader.SUPPORTS_LINE_OFFSET = True # No arguments, completely valid args, _ = parse_args(["lo...
def test_validate_filtering_args_with_valid_inputs():
fake_reader = logs.LogReader() fake_reader.SUPPORTS_TAILING = True fake_reader.SUPPORTS_LINE_COUNT = True fake_reader.SUPPORTS_TIME = True fake_reader.SUPPORTS_LINE_OFFSET = True # No arguments, completely valid args, _ = parse_args(["logs"]) assert logs.validate_filtering_args(args, fa...
"2016-06-06T20:25:49+00:00") def test_generate_start_end_time_invalid_to(): with pytest.raises(ValueError): logs.generate_start_end_time("2016-06-06T20:25:49+00:00", "invalid") def test_validate_filtering_args_with_valid_inputs():
71
71
238
10
61
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_validate_filtering_args_with_valid_inputs
test_validate_filtering_args_with_valid_inputs
1,138
1,159
1,138
1,138
b3d5ba1309ac28e4024d53fcb9341246a41b52a9
bigcode/the-stack
train
fb2a8c2f1a57de174cfd629a
train
function
@pytest.mark.skipif( not scribereader_available, reason="scribereader not available" ) # pragma: no cover (yelpy) def test_scribe_tail_ctrl_c(): env = "fake_env" stream_name = "fake_stream" service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["build", "deploy"] clu...
@pytest.mark.skipif( not scribereader_available, reason="scribereader not available" ) # pragma: no cover (yelpy) def test_scribe_tail_ctrl_c():
env = "fake_env" stream_name = "fake_stream" service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["build", "deploy"] clusters = ["fake_cluster1", "fake_cluster2"] queue = Queue() filter_fn = mock.Mock(return_value=True) with mock.patch( "paasta_tool...
_tail( env, stream_name, service, levels, components, clusters, queue, filter_fn ) assert queue.qsize() == 0 @pytest.mark.skipif( not scribereader_available, reason="scribereader not available" ) # pragma: no cover (yelpy) def test_scribe_tail_ctrl_c():
72
72
242
39
32
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_scribe_tail_ctrl_c
test_scribe_tail_ctrl_c
522
552
522
525
ac9d794257598d17e4e30d2fce7e2d3e1afa3e5a
bigcode/the-stack
train
b83794744d767afcec30a4f5
train
function
def test_tail_paasta_logs_ctrl_c_in_is_alive(): service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["deploy", "monitoring"] clusters = ["fake_cluster1", "fake_cluster2"] instances = ["fake_instance1", "fake_instance2"] with mock.patch( "paasta_tools.cli.cmds.lo...
def test_tail_paasta_logs_ctrl_c_in_is_alive():
service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["deploy", "monitoring"] clusters = ["fake_cluster1", "fake_cluster2"] instances = ["fake_instance1", "fake_instance2"] with mock.patch( "paasta_tools.cli.cmds.logs.ScribeLogReader.determine_scribereader_envs",...
_tools.cli.cmds.logs.scribereader", autospec=True ): fake_queue = mock.MagicMock(spec_set=Queue()) fake_queue.get.side_effect = FakeKeyboardInterrupt queue_patch.return_value = fake_queue with reraise_keyboardinterrupt(): logs.ScribeLogReader(cluster_map={}).tail_logs( ...
117
117
393
12
105
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_tail_paasta_logs_ctrl_c_in_is_alive
test_tail_paasta_logs_ctrl_c_in_is_alive
839
874
839
839
910f952ff6ab8e03f57d0aeafa1bf27befa19c17
bigcode/the-stack
train
252ed677e5b0da09a3f086d7
train
function
def test_marathon_log_line_passes_filter_fails_invalid_json(): assert not logs.marathon_log_line_passes_filter( "{ abcd }", None, None, None, None, None )
def test_marathon_log_line_passes_filter_fails_invalid_json():
assert not logs.marathon_log_line_passes_filter( "{ abcd }", None, None, None, None, None )
", autospec=True ) as format_job_id_patch: format_job_id_patch.return_value = service assert not logs.marathon_log_line_passes_filter( line, levels, service, components, clusters, instances ) def test_marathon_log_line_passes_filter_fails_invalid_json():
64
64
44
14
50
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_marathon_log_line_passes_filter_fails_invalid_json
test_marathon_log_line_passes_filter_fails_invalid_json
367
370
367
367
206a0f0418dc695dda95f9fa540aa20b1ff3da82
bigcode/the-stack
train
62b3f5daac3fdd25742c8a1e
train
function
def test_marathon_log_line_passes_filter_false_when_service_name_missing(): service = "fake_service" levels = [] components = [] clusters = [] instances = [] line = format_log_line( "fake_level", clusters, service, "fake_instance", "marathon", "fak...
def test_marathon_log_line_passes_filter_false_when_service_name_missing():
service = "fake_service" levels = [] components = [] clusters = [] instances = [] line = format_log_line( "fake_level", clusters, service, "fake_instance", "marathon", "fake message without service name", ) with mock.patch( "paasta...
", autospec=True ) as format_job_id_patch: format_job_id_patch.return_value = service assert logs.marathon_log_line_passes_filter( line, levels, service, components, clusters, instances ) def test_marathon_log_line_passes_filter_false_when_service_name_missing():
64
64
143
15
49
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_marathon_log_line_passes_filter_false_when_service_name_missing
test_marathon_log_line_passes_filter_false_when_service_name_missing
343
364
343
343
80a6b574801553cd5431c9b1d030c56c9ec98b3a
bigcode/the-stack
train
01177d73eca0eeee048445dc
train
function
def test_tail_paasta_logs_ctrl_c_in_queue_get(): service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["deploy", "monitoring", "stdout", "stderr"] clusters = ["fake_cluster1", "fake_cluster2"] instances = ["fake_instance1", "fake_instance2"] with mock.patch( "paa...
def test_tail_paasta_logs_ctrl_c_in_queue_get():
service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["deploy", "monitoring", "stdout", "stderr"] clusters = ["fake_cluster1", "fake_cluster2"] instances = ["fake_instance1", "fake_instance2"] with mock.patch( "paasta_tools.cli.cmds.logs.ScribeLogReader.determine...
(cluster_map={}).print_logs_by_time( service, start_time, end_time, levels, components, clusters, instances, raw_mode=False, ) # Please see comment in test_scribereader_print_last_n_logs for where this numbe...
92
92
309
12
79
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_tail_paasta_logs_ctrl_c_in_queue_get
test_tail_paasta_logs_ctrl_c_in_queue_get
806
834
806
806
a1cd2b60ac4ce60866473d3ff492a4ef324ace77
bigcode/the-stack
train
84a61be8462a593b1f0e2d52
train
function
@pytest.mark.skipif( not scribereader_available, reason="scribereader not available" ) # pragma: no cover (yelpy) def test_scribe_tail_log_nothing(): env = "fake_env" stream_name = "fake_stream" service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["build", "deploy"] ...
@pytest.mark.skipif( not scribereader_available, reason="scribereader not available" ) # pragma: no cover (yelpy) def test_scribe_tail_log_nothing():
env = "fake_env" stream_name = "fake_stream" service = "fake_service" levels = ["fake_level1", "fake_level2"] components = ["build", "deploy"] clusters = ["fake_cluster1", "fake_cluster2"] instance = "fake_instance" queue = Queue() filter_fn = mock.Mock(return_value=False) taile...
=True, timeout=0.1) assert "level: first. component: build." in first_line second_line = queue.get(block=True, queue=0.1) assert "level: second. component: deploy." in second_line @pytest.mark.skipif( not scribereader_available, reason="scribereader not available" ) # pragma: no cover (yelp...
93
93
313
40
52
sofyat/paasta
tests/cli/test_cmds_logs.py
Python
test_scribe_tail_log_nothing
test_scribe_tail_log_nothing
476
519
476
479
cecc9461d77f45b78e317dcdc9f33ecb2e407ea9
bigcode/the-stack
train
543c19f5eae68307109bc2fc
train
class
class ParamChange: """Value object for a parameter change.""" def __init__(self, name, generator_id, customization_args): """Initialize a ParamChange object with the specified arguments. Args: name: unicode. The name of the parameter. generator_id: unicode. The type of ...
class ParamChange:
"""Value object for a parameter change.""" def __init__(self, name, generator_id, customization_args): """Initialize a ParamChange object with the specified arguments. Args: name: unicode. The name of the parameter. generator_id: unicode. The type of generator used to c...
def to_dict(self): """Returns a dict representation of this ParamSpec. Returns: dict. A dict with a single key, whose value is the type of the parameter represented by this ParamSpec. """ return { 'obj_type': self.obj_type, } @classmetho...
255
256
1,046
4
251
yash10019coder/oppia
core/domain/param_domain.py
Python
ParamChange
ParamChange
77
211
77
77
407589ce387f0f2736af3a89c41e6860a48fe7cd
bigcode/the-stack
train
8781556c5f86088fc44ad88e
train
class
class ParamSpec: """Value object for an exploration parameter specification.""" def __init__(self, obj_type): """Initializes a ParamSpec object with the specified object type. Args: obj_type: unicode. The object type with which the parameter is initialized. ...
class ParamSpec:
"""Value object for an exploration parameter specification.""" def __init__(self, obj_type): """Initializes a ParamSpec object with the specified object type. Args: obj_type: unicode. The object type with which the parameter is initialized. """ self....
agreed to in writing, software # distributed under the License is distributed on an "AS-IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Domain objects relating to parameters....
96
96
321
4
91
yash10019coder/oppia
core/domain/param_domain.py
Python
ParamSpec
ParamSpec
28
74
28
28
f5f5db7af6b241f53d1c3af11c6d440743859572
bigcode/the-stack
train
bad7cb988c6d382c89f224fe
train
class
class Community(models.Model): key = models.CharField(unique=True, null=True , editable=False, max_length=500) name = models.CharField(_('community name'), max_length=200) slug = models.SlugField(_('community slug'),null=True,blank=True) created_at = models.DateTimeField(auto_now_add=True) upda...
class Community(models.Model):
key = models.CharField(unique=True, null=True , editable=False, max_length=500) name = models.CharField(_('community name'), max_length=200) slug = models.SlugField(_('community slug'),null=True,blank=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(au...
from django.db import models from django.utils.translation import ugettext_lazy as _ from django.utils.text import slugify from .managers import CommunityJoinRequestManager import shortuuid from base.models import Tag,CustomUser # Create your models here. class Community(models.Model):
59
64
177
5
54
abderrahmaneMustapha/CommunityLovers
community/models.py
Python
Community
Community
10
31
10
10
44c5a775992b2e74c91e5fa52b136292e711198a
bigcode/the-stack
train
f7b53f9d6a35e40661089479
train
class
class CommunityJoinRequest(models.Model): member = models.ForeignKey(CustomUser, verbose_name=_("user who sent request"),on_delete=models.CASCADE) community = models.ForeignKey(Community, verbose_name=_("request to joing this event"), on_delete=models.CASCADE) accepted = models.BooleanField("accept the...
class CommunityJoinRequest(models.Model):
member = models.ForeignKey(CustomUser, verbose_name=_("user who sent request"),on_delete=models.CASCADE) community = models.ForeignKey(Community, verbose_name=_("request to joing this event"), on_delete=models.CASCADE) accepted = models.BooleanField("accept the user in the community",default=False) ...
.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def get_owner(self): return self.owner class Meta: verbose_name = "Community owner" verbose_name_plural = "Community owners" def __str__(self): return str(self.owner.email) class ...
73
73
246
7
66
abderrahmaneMustapha/CommunityLovers
community/models.py
Python
CommunityJoinRequest
CommunityJoinRequest
48
69
48
48
ef6a1804fe2d293bef8198c7f3161414b8fdfddf
bigcode/the-stack
train
97b89787b778f7271d2bd3cb
train
class
class CommunityOwner(models.Model): owner = models.ForeignKey(CustomUser, on_delete=models.CASCADE, related_name="community_owner") community = models.ForeignKey(Community, on_delete=models.CASCADE ) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True...
class CommunityOwner(models.Model):
owner = models.ForeignKey(CustomUser, on_delete=models.CASCADE, related_name="community_owner") community = models.ForeignKey(Community, on_delete=models.CASCADE ) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def get_owner(self): ...
timestamps ''' self.key = shortuuid.uuid() self.slug= slugify("{} {}".format(self.name,self.key)) super(Community, self).save(*args, **kwargs) def __str__(self): return str(self.name) class CommunityOwner(models.Model):
64
64
111
6
58
abderrahmaneMustapha/CommunityLovers
community/models.py
Python
CommunityOwner
CommunityOwner
33
45
33
33
e61cf9f1f505e69eab457ded77b441f5b9c3b518
bigcode/the-stack
train
38aab9b67661cee4f9d3549f
train
class
class TMXmlTagTransferRNN: def __init__(self, langs, lazy=False): self.folder = os.path.join(DATA_DIR, '-'.join(langs)) self.pos_taggers = [TMPosTagger(lang.split('-')[0], universal=True) for lang in langs] self.model_dic = self.rnn = None if not lazy: try: self.model_dic, self.rnn = se...
class TMXmlTagTransferRNN:
def __init__(self, langs, lazy=False): self.folder = os.path.join(DATA_DIR, '-'.join(langs)) self.pos_taggers = [TMPosTagger(lang.split('-')[0], universal=True) for lang in langs] self.model_dic = self.rnn = None if not lazy: try: self.model_dic, self.rnn = self._load_rnn() except...
at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language gover...
256
256
2,749
8
247
shasha79/nectm
src/TMPreprocessor/Xml/TMXmlTagTransferRNN.py
Python
TMXmlTagTransferRNN
TMXmlTagTransferRNN
46
276
46
46
3e69cc8cdc3469bbcef1cadfa6d6cf0b34ee547c
bigcode/the-stack
train
5773b90b980743a268f00be9
train
class
class TestMungeFilename(object): # (original, expected) munge_list = [ ('unchanged', 'unchanged'), ('bad spaces', 'bad-spaces'), ('s', 's__'), # too short ('random:other%character&', 'randomothercharacter'), (u'u with umlaut \xfc', 'u-with-umlaut-u'), ('2014-11-...
class TestMungeFilename(object): # (original, expected)
munge_list = [ ('unchanged', 'unchanged'), ('bad spaces', 'bad-spaces'), ('s', 's__'), # too short ('random:other%character&', 'randomothercharacter'), (u'u with umlaut \xfc', 'u-with-umlaut-u'), ('2014-11-10 12:24:05.340603my_image.jpeg', '2014-11-10-122405...
) def test_munge_filename_multiple_pass(self): '''Munging filename multiple times produces same result.''' for org, exp in self.munge_list: first_munge = munge_filename_legacy(org) nose_tools.assert_equal(first_munge, exp) second_munge = munge_filename_legacy(fir...
97
97
325
14
83
ogdch/ckan
ckan/tests/lib/test_munge.py
Python
TestMungeFilename
TestMungeFilename
41
72
41
43
18224d8551b14b4f9d2a76c2c4cce494c7ac701d
bigcode/the-stack
train
080f54f5fdd153df52551378
train
class
class TestMungeTitleToName(object): # (original, expected) munge_list = [ ('unchanged', 'unchanged'), ('some spaces here', 'some-spaces-here'), ('s', 's_'), # too short ('random:other%character&', 'random-othercharacter'), (u'u with umlaut \xfc', 'u-with-umlaut-u'), ...
class TestMungeTitleToName(object): # (original, expected)
munge_list = [ ('unchanged', 'unchanged'), ('some spaces here', 'some-spaces-here'), ('s', 's_'), # too short ('random:other%character&', 'random-othercharacter'), (u'u with umlaut \xfc', 'u-with-umlaut-u'), ('reallylong' * 12, 'reallylong' * 9 + 'reall'), (...
''' for org, exp in self.munge_list: first_munge = munge_name(org) nose_tools.assert_equal(first_munge, exp) second_munge = munge_name(first_munge) nose_tools.assert_equal(second_munge, exp) class TestMungeTitleToName(object): # (original, expected)
72
72
242
16
56
ogdch/ckan
ckan/tests/lib/test_munge.py
Python
TestMungeTitleToName
TestMungeTitleToName
102
121
102
104
af3777d05070506fcc092d2983382b8aa01b6cb6
bigcode/the-stack
train
d2a69a3ddbe63fa0709c5315
train
class
class TestMungeName(object): # (original, expected) munge_list = [ ('unchanged', 'unchanged'), ('bad spaces', 'bad-spaces'), ('s', 's_'), # too short ('random:other%character&', 'random-othercharacter'), (u'u with umlaut \xfc', 'u-with-umlaut-u'), ('2014-11-10 1...
class TestMungeName(object): # (original, expected)
munge_list = [ ('unchanged', 'unchanged'), ('bad spaces', 'bad-spaces'), ('s', 's_'), # too short ('random:other%character&', 'random-othercharacter'), (u'u with umlaut \xfc', 'u-with-umlaut-u'), ('2014-11-10 12:24:05.my_image', '2014-11-10-12-24-05-my_image') ] ...
produces same result.''' for org, exp in self.munge_list: first_munge = munge_filename(org) nose_tools.assert_equal(first_munge, exp) second_munge = munge_filename(first_munge) nose_tools.assert_equal(second_munge, exp) class TestMungeName(object): # (origin...
74
74
248
14
60
ogdch/ckan
ckan/tests/lib/test_munge.py
Python
TestMungeName
TestMungeName
75
99
75
77
4eb28295c680dba89f72d21f6302017f4675f756
bigcode/the-stack
train
7d43447b8dd8dae49762d908
train
class
class TestMungeTag: # (original, expected) munge_list = [ ('unchanged', 'unchanged'), ('s', 's_'), # too short ('some spaces here', 'some-spaces--here'), ('random:other%character&', 'randomothercharacter') ] def test_munge_tag(self): '''Munge a list of tags gi...
class TestMungeTag: # (original, expected)
munge_list = [ ('unchanged', 'unchanged'), ('s', 's_'), # too short ('some spaces here', 'some-spaces--here'), ('random:other%character&', 'randomothercharacter') ] def test_munge_tag(self): '''Munge a list of tags gives expected results.''' for org, exp in...
unge_title_to_name(self): '''Munge a list of names gives expected results.''' for org, exp in self.munge_list: munge = munge_title_to_name(org) nose_tools.assert_equal(munge, exp) class TestMungeTag: # (original, expected)
64
64
204
13
51
ogdch/ckan
ckan/tests/lib/test_munge.py
Python
TestMungeTag
TestMungeTag
124
146
124
126
11a60788a31b14870ee674ad8c51aa60cb80b518
bigcode/the-stack
train
1e85f60e30531d20265e2bec
train
class
class TestMungeFilenameLegacy(object): # (original, expected) munge_list = [ ('unchanged', 'unchanged'), ('bad spaces', 'bad-spaces'), ('s', 's__'), # too short ('random:other%character&', 'randomothercharacter'), (u'u with umlaut \xfc', 'u-with-umlaut-u'), ('20...
class TestMungeFilenameLegacy(object): # (original, expected)
munge_list = [ ('unchanged', 'unchanged'), ('bad spaces', 'bad-spaces'), ('s', 's__'), # too short ('random:other%character&', 'randomothercharacter'), (u'u with umlaut \xfc', 'u-with-umlaut-u'), ('2014-11-10 12:24:05.340603my_image.jpeg', '2014-11-10-122405...
from nose import tools as nose_tools from ckan.lib.munge import (munge_filename_legacy, munge_filename, munge_name, munge_title_to_name, munge_tag) class TestMungeFilenameLegacy(object): # (original, expected)
56
99
331
15
41
ogdch/ckan
ckan/tests/lib/test_munge.py
Python
TestMungeFilenameLegacy
TestMungeFilenameLegacy
7
38
7
9
09dca96e75edf0422b8a107b3f8954b1f92e002a
bigcode/the-stack
train
8bfbbcfaeeefe0da2a453b0f
train
function
@pytest.fixture() def kid(): "The Key ID we expect for the above public key" return "307a30c3-8280-4ff5-a78d-6bc5263ffbe8"
@pytest.fixture() def kid():
"The Key ID we expect for the above public key" return "307a30c3-8280-4ff5-a78d-6bc5263ffbe8"
the Werkzeug test Client # and handling the context locals for you. testing_client = app.test_client() # Establish an application context before running the tests. ctx = app.app_context() ctx.push() return testing_client # this is where the testing happens! @pytest.fixture() def kid():
64
64
46
6
58
lunarfish/flask-static-auth-wrapper
staticauth/conftest.py
Python
kid
kid
18
21
18
19
abd3d35c066b2db6648dc52c0634d19bb1a9831a
bigcode/the-stack
train
03f565aad364de98521e2aff
train
function
@pytest.fixture() def test_session(): return get_default_session()
@pytest.fixture() def test_session():
return get_default_session()
_session(): session = { "state": "abc123", "user_info": { "name": "Test User", "email": "test.user@test-domain.com", "roles": ["user-role-1"], }, } return session @pytest.fixture() def test_session():
64
64
13
7
56
lunarfish/flask-static-auth-wrapper
staticauth/conftest.py
Python
test_session
test_session
128
130
128
129
2ca7fd806392a621431e82545dbafad18b20a256
bigcode/the-stack
train
820d8a0c5030e225f2f3bcae
train
function
@pytest.fixture() def request_home(): group = "target_group_x/123456" account = "123456789012" service = "elasticloadbalancing" target_group = f"arn:aws:{service}:eu-west-2:{account}:targetgroup/{group}" user_agent = "Mozilla/5.0" return { "requestContext": {"elb": {"targetGroupArn": tar...
@pytest.fixture() def request_home():
group = "target_group_x/123456" account = "123456789012" service = "elasticloadbalancing" target_group = f"arn:aws:{service}:eu-west-2:{account}:targetgroup/{group}" user_agent = "Mozilla/5.0" return { "requestContext": {"elb": {"targetGroupArn": target_group}}, "httpMethod": "GE...
. ctx = app.app_context() ctx.push() return testing_client # this is where the testing happens! @pytest.fixture() def kid(): "The Key ID we expect for the above public key" return "307a30c3-8280-4ff5-a78d-6bc5263ffbe8" @pytest.fixture() def request_home():
78
78
262
7
71
lunarfish/flask-static-auth-wrapper
staticauth/conftest.py
Python
request_home
request_home
24
49
24
25
ae25f6410a07aa7671772444f36db531796c8348
bigcode/the-stack
train
6185bc80bafabe980181cd18
train
function
def get_oidc_root(): return "https://oidc.test.domain/auth/root/"
def get_oidc_root():
return "https://oidc.test.domain/auth/root/"
user_agent, "x-forwarded-for": "81.104.91.14", "x-forwarded-port": "443", "x-forwarded-proto": "https", }, "body": "", "isBase64Encoded": True, } def get_oidc_root():
64
64
18
6
58
lunarfish/flask-static-auth-wrapper
staticauth/conftest.py
Python
get_oidc_root
get_oidc_root
52
53
52
52
f0c21d8a1a61a09202d8a6ca00e2c1b1e4ada0ac
bigcode/the-stack
train
2ced3b0102cf4044d72c34a5
train
function
@pytest.fixture() def openid_config(): here = os.path.dirname(os.path.abspath(__file__)) with open(f"{here}/tests/mock/openid-configuration.json", "r") as config: content = config.read() return content
@pytest.fixture() def openid_config():
here = os.path.dirname(os.path.abspath(__file__)) with open(f"{here}/tests/mock/openid-configuration.json", "r") as config: content = config.read() return content
"user_info": { "name": "Test User", "email": "test.user@test-domain.com", "roles": ["user-role-1"], }, } return session @pytest.fixture() def test_session(): return get_default_session() @pytest.fixture() def openid_config():
64
64
51
8
56
lunarfish/flask-static-auth-wrapper
staticauth/conftest.py
Python
openid_config
openid_config
133
138
133
134
0a390f97088bdf0ed0a681c056a5da10321f2273
bigcode/the-stack
train
5328ec4ffd867bfd8428615b
train
function
def get_test_client(app): # Flask provides a way to test your application by exposing the Werkzeug test Client # and handling the context locals for you. testing_client = app.test_client() # Establish an application context before running the tests. ctx = app.app_context() ctx.push() retur...
def get_test_client(app): # Flask provides a way to test your application by exposing the Werkzeug test Client # and handling the context locals for you.
testing_client = app.test_client() # Establish an application context before running the tests. ctx = app.app_context() ctx.push() return testing_client # this is where the testing happens!
import os import pytest def get_test_client(app): # Flask provides a way to test your application by exposing the Werkzeug test Client # and handling the context locals for you.
39
64
76
33
5
lunarfish/flask-static-auth-wrapper
staticauth/conftest.py
Python
get_test_client
get_test_client
6
15
6
8
27c4a54e1ac36402f97c653cfbc1c67fa54f190d
bigcode/the-stack
train
7b821872322e4e8ae5d223f4
train
function
@pytest.fixture() def static_home(): module_path = os.path.dirname(os.path.abspath(__file__)) with open(f"{module_path}/tests/static/index.html", "r") as page_file: page_content = page_file.read() return page_content
@pytest.fixture() def static_home():
module_path = os.path.dirname(os.path.abspath(__file__)) with open(f"{module_path}/tests/static/index.html", "r") as page_file: page_content = page_file.read() return page_content
/secret_key": "flask-secret", "/oidc/endpoint": get_oidc_root(), "/oidc/client_id": "oidc-client-id", "/oidc/client_secret": "oidc-client-secret", # pragma: allowlist secret } @pytest.fixture() def static_home():
64
64
53
7
57
lunarfish/flask-static-auth-wrapper
staticauth/conftest.py
Python
static_home
static_home
66
71
66
67
81475ca4e43e2af41aac2ac8f5e53eecf9932444
bigcode/the-stack
train
6052f555fc051713fd270934
train
function
@pytest.fixture() def access_controls(): controls = { "paths": { "/index.html": {"open_access": True}, "/user-role-one": { "message": "You need to be granted the incident-management role.", "open_access": False, "role_requirements": [{"...
@pytest.fixture() def access_controls():
controls = { "paths": { "/index.html": {"open_access": True}, "/user-role-one": { "message": "You need to be granted the incident-management role.", "open_access": False, "role_requirements": [{"type": "all", "roles": ["user-role-1"]}],...
endpoint": get_oidc_root(), "/oidc/client_id": "oidc-client-id", "/oidc/client_secret": "oidc-client-secret", # pragma: allowlist secret } @pytest.fixture() def static_home(): module_path = os.path.dirname(os.path.abspath(__file__)) with open(f"{module_path}/tests/static/index.html", "r")...
103
103
346
7
95
lunarfish/flask-static-auth-wrapper
staticauth/conftest.py
Python
access_controls
access_controls
74
113
74
75
c8b2e7676c7ba69ad13476b75a7fd7cb9e20e88f
bigcode/the-stack
train
0244b7c66ca4491dc649a9d3
train
function
@pytest.fixture() def test_ssm_parameters(): return { "/flask/secret_key": "flask-secret", "/oidc/endpoint": get_oidc_root(), "/oidc/client_id": "oidc-client-id", "/oidc/client_secret": "oidc-client-secret", # pragma: allowlist secret }
@pytest.fixture() def test_ssm_parameters():
return { "/flask/secret_key": "flask-secret", "/oidc/endpoint": get_oidc_root(), "/oidc/client_id": "oidc-client-id", "/oidc/client_secret": "oidc-client-secret", # pragma: allowlist secret }
-forwarded-port": "443", "x-forwarded-proto": "https", }, "body": "", "isBase64Encoded": True, } def get_oidc_root(): return "https://oidc.test.domain/auth/root/" @pytest.fixture() def test_ssm_parameters():
63
64
73
9
54
lunarfish/flask-static-auth-wrapper
staticauth/conftest.py
Python
test_ssm_parameters
test_ssm_parameters
56
63
56
57
d9d310673dd62fc50821e150eb7b462010672566
bigcode/the-stack
train
5ea7190a6d27b42f8da58916
train
function
def get_default_session(): session = { "state": "abc123", "user_info": { "name": "Test User", "email": "test.user@test-domain.com", "roles": ["user-role-1"], }, } return session
def get_default_session():
session = { "state": "abc123", "user_info": { "name": "Test User", "email": "test.user@test-domain.com", "roles": ["user-role-1"], }, } return session
"role_requirements": [ {"type": "any", "roles": ["user-role-1", "user-role-2"]}, {"type": "all", "roles": ["user-role-3"]}, ], }, } } return controls def get_default_session():
64
64
60
5
58
lunarfish/flask-static-auth-wrapper
staticauth/conftest.py
Python
get_default_session
get_default_session
116
125
116
116
9903898fdb14fd3242ecef9f738c9f895572393d
bigcode/the-stack
train
4991df0a66ab49b9de62ed8c
train
class
@requires_babel class MakoExtractTest(TemplateTest): def test_extract(self): with open( os.path.join(config.template_base, "gettext.mako") ) as mako_tmpl: messages = list( extract( mako_tmpl, {"_": None, "gettext": None,...
@requires_babel class MakoExtractTest(TemplateTest):
def test_extract(self): with open( os.path.join(config.template_base, "gettext.mako") ) as mako_tmpl: messages = list( extract( mako_tmpl, {"_": None, "gettext": None, "ungettext": (1, 2)}, ["TRANSLAT...
list(extract(input_, ["_"], [], {})) eq_(messages, [(1, "_", ("Message"), [])]) def test_python_gettext_call(self): input_ = io.BytesIO(b'<p>${_("Message")}</p>') messages = list(extract(input_, ["_"], [], {})) eq_(messages, [(1, "_", ("Message"), [])]) def test_translator_com...
201
201
671
14
187
val-verde/python-mako
test/ext/test_babelplugin.py
Python
MakoExtractTest
MakoExtractTest
45
103
45
46
7a9556a0eec3f86b7d6773b3b85ff237c6ac0ba5
bigcode/the-stack
train
3fc90f32678fd8ec139f6c75
train
class
@requires_babel class PluginExtractTest: def test_parse_python_expression(self): input_ = io.BytesIO(b'<p>${_("Message")}</p>') messages = list(extract(input_, ["_"], [], {})) eq_(messages, [(1, "_", ("Message"), [])]) def test_python_gettext_call(self): input_ = io.BytesIO(b'<p...
@requires_babel class PluginExtractTest:
def test_parse_python_expression(self): input_ = io.BytesIO(b'<p>${_("Message")}</p>') messages = list(extract(input_, ["_"], [], {})) eq_(messages, [(1, "_", ("Message"), [])]) def test_python_gettext_call(self): input_ = io.BytesIO(b'<p>${_("Message")}</p>') messages =...
import io import os from mako.ext.babelplugin import extract from mako.testing.assertions import eq_ from mako.testing.config import config from mako.testing.exclusions import requires_babel from mako.testing.fixtures import TemplateTest @requires_babel class PluginExtractTest:
64
67
225
10
53
val-verde/python-mako
test/ext/test_babelplugin.py
Python
PluginExtractTest
PluginExtractTest
11
42
11
12
8b0da4dacc348006c886dbe4b313a1bd78a9b6d8
bigcode/the-stack
train
67414078b0b31647092f3f04
train
class
class SecurityContext(object): '''This class provides the OAuth2 security context. Security context is available for each request and can be accessed using the following code snippet: .. code-block:: python @Controller(url="/test/controller") def handle_request(self, request): sec...
class SecurityContext(object):
'''This class provides the OAuth2 security context. Security context is available for each request and can be accessed using the following code snippet: .. code-block:: python @Controller(url="/test/controller") def handle_request(self, request): security_ctx = request.context.sec...
AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT O...
127
127
426
5
122
bopopescu/fantastico
fantastico/oauth2/security_context.py
Python
SecurityContext
SecurityContext
20
72
20
20
6317ee2bd787091083094c3ad7235b215ebcc6e6
bigcode/the-stack
train
8bcb8d656c65c2a7d53302ea
train
function
def to_jsonable_dict(skip_keys=list()): dict(to_jsonable_dict(skip_keys=skip_keys))
def to_jsonable_dict(skip_keys=list()):
dict(to_jsonable_dict(skip_keys=skip_keys))
# -*- coding: utf-8 -*- from datetime import datetime from . import py2 __author__ = 'luckydonald' def to_jsonable_dict(skip_keys=list()):
38
64
21
9
29
luckydonald/python-utils
luckydonaldUtils/json.py
Python
to_jsonable_dict
to_jsonable_dict
8
9
8
8
0357d370dcaa607cffcac7dd9f78079eddf36973
bigcode/the-stack
train
c82d9f78ced96d8ea1a88191
train
function
def run(): build_dir = libtbx.env.under_build("simtbx") dist_dir = libtbx.env.dist_path("simtbx") test_utils.run_tests(build_dir, dist_dir, tst_list)
def run():
build_dir = libtbx.env.under_build("simtbx") dist_dir = libtbx.env.dist_path("simtbx") test_utils.run_tests(build_dir, dist_dir, tst_list)
_parallel = [ ["$D/nanoBragg/tst_gauss_argchk_gpu.py","GPU"] # tests CPU+GPU, argchk optimization ] else: tst_list.append( ["$D/nanoBragg/tst_gauss_argchk.py","CPU"] ) def run():
64
64
48
3
61
pcxod/cctbx_project
simtbx/run_tests.py
Python
run
run
24
27
24
24
4a5d3205b45327543ceb3d79ce25fe9b3cfa8794
bigcode/the-stack
train
18072806d8122aff76b6d650
train
class
class PosixPipeInput(Vt100Input, PipeInput): """ Input that is send through a pipe. This is useful if we want to send the input programmatically into the application. Mostly useful for unit testing. Usage:: input = PosixPipeInput() input.send_text('inputdata') """ _id = 0 ...
class PosixPipeInput(Vt100Input, PipeInput):
""" Input that is send through a pipe. This is useful if we want to send the input programmatically into the application. Mostly useful for unit testing. Usage:: input = PosixPipeInput() input.send_text('inputdata') """ _id = 0 def __init__(self, text: str = "") -> No...
import os from typing import ContextManager, TextIO, cast from ..utils import DummyContext from .base import PipeInput from .vt100 import Vt100Input __all__ = [ "PosixPipeInput", ] class PosixPipeInput(Vt100Input, PipeInput):
64
122
407
13
51
ajayiagbebaku/NFL-Model
venv/Lib/site-packages/prompt_toolkit/input/posix_pipe.py
Python
PosixPipeInput
PosixPipeInput
13
72
13
13
3fddf7fcdb46310c52a1de7ca39e92eecdf72830
bigcode/the-stack
train
1ae29d9e3ba60cb22d73ad4c
train
class
class UploadCommand(Command): """Support setup.py upload.""" description = 'Build and publish the package.' user_options = [] @staticmethod def status(s): """Prints things in bold.""" print('\033[1m{0}\033[0m'.format(s)) def initialize_options(self): pass def fina...
class UploadCommand(Command):
"""Support setup.py upload.""" description = 'Build and publish the package.' user_options = [] @staticmethod def status(s): """Prints things in bold.""" print('\033[1m{0}\033[0m'.format(s)) def initialize_options(self): pass def finalize_options(self): pa...
from shutil import rmtree from setuptools import Command, setup, find_packages here = os.path.abspath(os.path.dirname(__file__)) VERSION = __import__('jackal').__version__ def read(f): return open(f, 'r', encoding='utf-8').read() class UploadCommand(Command):
64
64
212
5
59
joyongjin/Jackal
setup.py
Python
UploadCommand
UploadCommand
17
48
17
17
c42df136bde5b62493c2181ee405b9bcfc0d9360
bigcode/the-stack
train
6af25aa72c071c1219db58cb
train
function
def read(f): return open(f, 'r', encoding='utf-8').read()
def read(f):
return open(f, 'r', encoding='utf-8').read()
#!/usr/bin/env python import os import sys from shutil import rmtree from setuptools import Command, setup, find_packages here = os.path.abspath(os.path.dirname(__file__)) VERSION = __import__('jackal').__version__ def read(f):
54
64
20
4
50
joyongjin/Jackal
setup.py
Python
read
read
13
14
13
13
3dfbf55e605a6a1795c7fa4749a8caeb3575f039
bigcode/the-stack
train
d2d3d305f67dade86acd1ddc
train
class
class Measurement(object): """Implements a class to describe a quantity with uncertainty. :param value: The most likely value of the measurement. :type value: Quantity or Number :param error: The error or uncertainty of the measurement. :type value: Quantity or Number """ def __init__(self...
class Measurement(object):
"""Implements a class to describe a quantity with uncertainty. :param value: The most likely value of the measurement. :type value: Quantity or Number :param error: The error or uncertainty of the measurement. :type value: Quantity or Number """ def __init__(self, value, error): if...
# -*- coding: utf-8 -*- """ pint.measurement ~~~~~~~~~~~~~~~~ :copyright: 2013 by Pint Authors, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ from __future__ import division, unicode_literals, print_function, absolute_import import operator class Measurement(object):...
73
237
790
4
68
Vinicius-Tanigawa/Undergraduate-Research-Project
SUAVE/SUAVE-2.5.0/trunk/SUAVE/Plugins/pint/measurement.py
Python
Measurement
Measurement
16
124
16
16
0909311d017ce45b0dfca12c391e0d793e73270f
bigcode/the-stack
train
df338d8367a581993c288d99
train
function
@pytest.fixture() def color_lang(): vector_data = { "red": np.array([1.0, 0.0]), "green": np.array([0.5, 0.5]), "blue": np.array([0.0, 1.0]), "purple": np.array([0.0, 1.0]), } vocab = Vocab(strings=list(vector_data.keys())) for word, vector in vector_data.items(): ...
@pytest.fixture() def color_lang():
vector_data = { "red": np.array([1.0, 0.0]), "green": np.array([0.5, 0.5]), "blue": np.array([0.0, 1.0]), "purple": np.array([0.0, 1.0]), } vocab = Vocab(strings=list(vector_data.keys())) for word, vector in vector_data.items(): vocab.set_vector(word, vector) ...
import pytest import numpy as np from spacy.vocab import Vocab from spacy.language import Language from whatlies.language import SpacyLanguage @pytest.fixture() def color_lang():
40
64
125
7
32
nth-attempt/whatlies
tests/test_lang/test_spacy_language.py
Python
color_lang
color_lang
9
22
9
10
14f5b6968b581af443c3c99763ad2fcb7e50e5c0
bigcode/the-stack
train
956206961c6068912bf9806a
train
function
def test_basic_usage(color_lang): queries = [ "green is blue and yellow", "purple is red and blue", "purple isn't same as red!", "red and blue is a like a glue!", ] emb = color_lang[queries] assert len(emb) == 4 assert emb[queries[0]].name == "green is blue and yellow...
def test_basic_usage(color_lang):
queries = [ "green is blue and yellow", "purple is red and blue", "purple isn't same as red!", "red and blue is a like a glue!", ] emb = color_lang[queries] assert len(emb) == 4 assert emb[queries[0]].name == "green is blue and yellow" assert emb[queries[0]].vecto...
.0, 1.0]), } vocab = Vocab(strings=list(vector_data.keys())) for word, vector in vector_data.items(): vocab.set_vector(word, vector) nlp = Language(vocab=vocab) return SpacyLanguage(nlp) def test_basic_usage(color_lang):
64
64
97
7
57
nth-attempt/whatlies
tests/test_lang/test_spacy_language.py
Python
test_basic_usage
test_basic_usage
25
35
25
25
12300513873d017409d2c2862cf2921f038b2b4d
bigcode/the-stack
train
eaf80589fadf63d96eec6305
train
function
def test_score_similar_one(color_lang): scores = color_lang.score_similar("blue", n=2, prob_limit=None, lower=False) print(scores) assert all([s[1] == 0 for s in scores]) assert "blue" in [s[0].name for s in scores] assert "purple" in [s[0].name for s in scores]
def test_score_similar_one(color_lang):
scores = color_lang.score_similar("blue", n=2, prob_limit=None, lower=False) print(scores) assert all([s[1] == 0 for s in scores]) assert "blue" in [s[0].name for s in scores] assert "purple" in [s[0].name for s in scores]
a glue!", ] emb = color_lang[queries] assert len(emb) == 4 assert emb[queries[0]].name == "green is blue and yellow" assert emb[queries[0]].vector.shape == (2,) def test_score_similar_one(color_lang):
63
64
85
9
54
nth-attempt/whatlies
tests/test_lang/test_spacy_language.py
Python
test_score_similar_one
test_score_similar_one
38
43
38
38
3c93fa6375969fcb87e4b6c536ecf950c0369c7b
bigcode/the-stack
train
86ea7900f587396f83056f1a
train
function
def test_single_token_words(color_lang): # test for issue here: https://github.com/RasaHQ/whatlies/issues/5 assert len(color_lang["red"].vector) > 0
def test_single_token_words(color_lang): # test for issue here: https://github.com/RasaHQ/whatlies/issues/5
assert len(color_lang["red"].vector) > 0
]) assert "blue" in [s[0].name for s in scores] assert "purple" in [s[0].name for s in scores] def test_single_token_words(color_lang): # test for issue here: https://github.com/RasaHQ/whatlies/issues/5
64
64
43
29
35
nth-attempt/whatlies
tests/test_lang/test_spacy_language.py
Python
test_single_token_words
test_single_token_words
46
48
46
47
f01107b597fb69de2e9184611486524b9518559e
bigcode/the-stack
train
966fc3aa01321b5ad0c1bf9a
train
class
@DATASETS.register_module() class ADE20KDataset(CustomDataset): """ADE20K dataset. In segmentation map annotation for ADE20K, 0 stands for background, which is not included in 150 categories. ``reduce_zero_label`` is fixed to True. The ``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is fixed t...
@DATASETS.register_module() class ADE20KDataset(CustomDataset):
"""ADE20K dataset. In segmentation map annotation for ADE20K, 0 stands for background, which is not included in 150 categories. ``reduce_zero_label`` is fixed to True. The ``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is fixed to '.png'. """ CLASSES = ('foreground') PALETTE ...
from .builder import DATASETS from .custom import CustomDataset @DATASETS.register_module() class ADE20KDataset(CustomDataset):
28
64
152
14
13
kartikwar/Swin-Transformer-Semantic-Segmentation
mmseg/datasets/ade.py
Python
ADE20KDataset
ADE20KDataset
5
23
5
6
15919490679d91cb3bde366f81ce1809644b4df3
bigcode/the-stack
train
e284fbdea48643805015fc0b
train
function
def delete(url, **kwargs): r"""Sends a DELETE request. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response """ return request("delete", url, **kwargs)
def delete(url, **kwargs):
r"""Sends a DELETE request. :param url: URL for the new :class:`Request` object. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response """ return request("delete", url, **kwargs)
:class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object :rtype: requests.Response """ return request("patch", url, data=data, **kwargs) def delete(url, **kwargs):
64
64
81
7
57
aitoehigie/britecore_flask
venv/lib/python3.6/site-packages/requests/api.py
Python
delete
delete
149
158
149
149
d8d7144135ea2fc562b6af285eec126f401736d4
bigcode/the-stack
train