예제 #1
0
 def test_plugins_not_allowed(self) -> None:
     result = Aggregator(
         RuntimeConfig(
             _paths=[],
             are_plugins_allowed=False,
         ))()
     assert result == 0
예제 #2
0
 def test_aggregator_invalid(self) -> None:
     stdin = OpenBytesIO((TEST_DATA / "invalid.py").read_bytes())
     stdout = OpenBytesIO()
     result = Aggregator(
         RuntimeConfig(
             _config=CONFIG,
             _paths=[StdPath("-").with_streams(stdin=stdin, stdout=stdout)],
             show_header=True,
         ))()
     assert result == 1
     assert stdout.read().decode("utf-8") == ""
예제 #3
0
 def test_invalid_config(self) -> None:
     stdin = OpenBytesIO((TEST_DATA / "output_grouped.py").read_bytes())
     stdout = OpenBytesIO()
     result = Aggregator(
         RuntimeConfig(
             config_path=__file__,
             _paths=[StdPath("-").with_streams(stdin=stdin, stdout=stdout)],
             show_header=True,
         ))()
     assert result == 1
     assert stdout.read().decode("utf-8") == ""
예제 #4
0
 def test_aggregator_no_changes(self) -> None:
     stdin = OpenBytesIO((TEST_DATA / "output_grouped.py").read_bytes())
     stdout = OpenBytesIO()
     result = Aggregator(
         RuntimeConfig(
             _config=CONFIG,
             _paths=[StdPath("-").with_streams(stdin=stdin, stdout=stdout)],
             show_header=True,
             is_subconfig_allowed=False,
         ))()
     assert result == 0
     assert stdout.read().decode("utf-8") == ""
예제 #5
0
 def test_aggregator_subconfig(self) -> None:
     stdout = OpenBytesIO()
     result = Aggregator(
         RuntimeConfig(
             _config=CONFIG,
             _paths=[
                 StdPath(
                     TEST_DATA / "subconfig" /
                     "input_few_imports.py").with_streams(fileout=stdout)
             ],
             show_header=True,
         ))()
     assert result == 0
     assert (TEST_DATA / "subconfig" / "output_grouped_few_imports.py"
             ).read_text() in stdout.read().decode("utf-8")
예제 #6
0
 def test_no_plugins(self) -> None:
     result = Aggregator(RuntimeConfig(_paths=[],
                                       are_plugins_allowed=True))()
     assert result == 0