Skip to content

Commit b3fa7e3

Browse files
chore: fix warnings in tests (#49)
* chore: fix warnings in tests * use run_path instead of run module
1 parent a0f3e68 commit b3fa7e3

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

tests/scenario_test/test_get_hooks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
class TestGetHooks:
1010

1111
def setup_method(self):
12-
cli_args = [get_hooks.__name__, "--protocol", "message-boundaries", "--boundary", ""]
12+
cli_args = [get_hooks.__file__, "--protocol", "message-boundaries", "--boundary", ""]
1313
self.argv_mock = patch.object(sys, "argv", cli_args)
1414
self.argv_mock.start()
1515

1616
def teardown_method(self):
1717
self.argv_mock.stop()
1818

1919
def test_get_manifest(self, capsys):
20-
runpy.run_module(get_hooks.__name__, run_name="__main__")
20+
runpy.run_path(get_hooks.__file__, run_name="__main__")
2121

2222
out, err = capsys.readouterr()
2323
json_response = json.loads(out)
@@ -26,7 +26,7 @@ def test_get_manifest(self, capsys):
2626
assert get_manifest.__name__ in json_response["hooks"]["get-manifest"]
2727

2828
def test_start(self, capsys):
29-
runpy.run_module(get_hooks.__name__, run_name="__main__")
29+
runpy.run_path(get_hooks.__file__, run_name="__main__")
3030

3131
out, err = capsys.readouterr()
3232
json_response = json.loads(out)

tests/scenario_test/test_get_manifest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class TestGetManifest:
1414

1515
def setup_method(self):
16-
cli_args = [get_manifest.__name__, "--protocol", "message-boundaries", "--boundary", ""]
16+
cli_args = [get_manifest.__file__, "--protocol", "message-boundaries", "--boundary", ""]
1717
self.argv_mock = patch.object(sys, "argv", cli_args)
1818
self.argv_mock.start()
1919
self.cwd = os.getcwd()
@@ -26,7 +26,7 @@ def test_get_manifest_script(self, capsys):
2626
working_directory = "tests/scenario_test/test_app"
2727
os.chdir(working_directory)
2828

29-
runpy.run_module(get_manifest.__name__, run_name="__main__")
29+
runpy.run_path(get_manifest.__file__, run_name="__main__")
3030

3131
out, err = capsys.readouterr()
3232
assert err == ""
@@ -37,6 +37,6 @@ def test_get_manifest_script_no_manifest(self):
3737
os.chdir(working_directory)
3838

3939
with pytest.raises(CliError) as e:
40-
runpy.run_module(get_manifest.__name__, run_name="__main__")
40+
runpy.run_path(get_manifest.__file__, run_name="__main__")
4141

4242
assert str(e.value) == "Could not find a manifest.json file"

tests/scenario_test/test_start.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def setup_method(self):
2222
setup_mock_web_api_server(self)
2323
start_socket_mode_server(self, 3012)
2424

25-
cli_args = [start.__name__, "--protocol", "message-boundaries", "--boundary", ""]
25+
cli_args = [start.__file__, "--protocol", "message-boundaries", "--boundary", ""]
2626
self.argv_mock = patch.object(sys, "argv", cli_args)
2727
self.argv_mock.start()
2828

@@ -41,7 +41,7 @@ def teardown_method(self):
4141
def test_start_script(self, capsys, caplog):
4242
os.chdir(self.working_directory)
4343

44-
runpy.run_module(start.__name__, run_name="__main__")
44+
runpy.run_path(start.__file__, run_name="__main__")
4545

4646
captured_sys = capsys.readouterr()
4747

@@ -52,7 +52,7 @@ def test_start_with_entrypoint(self, capsys, caplog):
5252
os.environ["SLACK_APP_PATH"] = "my_app.py"
5353
os.chdir(self.working_directory)
5454

55-
runpy.run_module(start.__name__, run_name="__main__")
55+
runpy.run_path(start.__file__, run_name="__main__")
5656

5757
captured_sys = capsys.readouterr()
5858

@@ -64,6 +64,6 @@ def test_start_no_entrypoint(self):
6464
os.chdir(working_directory)
6565

6666
with pytest.raises(CliError) as e:
67-
runpy.run_module(start.__name__, run_name="__main__")
67+
runpy.run_path(start.__file__, run_name="__main__")
6868

6969
assert "Could not find app.py file" in str(e.value)

0 commit comments

Comments
 (0)