def test_command_line_arguments_yes_no( mock_writer: mock.MagicMock, # pylint: disable=unused-argument ) -> None: """Regression test for the --module-names option. Make sure that we supprot --module-names=yes syntax instead of using it as a flag. """ with pytest.raises(SystemExit) as wrapped_sysexit: main.Run(["--module-names=yes", TEST_DATA_DIR]) assert wrapped_sysexit.value.code == 0
def test_graphviz_supported_image_format(mock_writer, capsys): """Test that Graphviz is used if the image format is supported.""" with pytest.raises(SystemExit) as wrapped_sysexit: # we have to catch the SystemExit so the test execution does not stop main.Run(["-o", "png", TEST_DATA_DIR]) # Check that the right info message is shown to the user assert ( "Format png is not supported natively. Pyreverse will try to generate it using Graphviz..." in capsys.readouterr().out) # Check that pyreverse actually made the call to create the diagram and we exit cleanly mock_writer.DiagramWriter().write.assert_called_once() assert wrapped_sysexit.value.code == 0
def test_graphviz_cant_determine_supported_formats(mock_writer, mock_subprocess, capsys): """Test that Graphviz is used if the image format is supported.""" mock_subprocess.run.return_value.stderr = "..." with pytest.raises(SystemExit) as wrapped_sysexit: # we have to catch the SystemExit so the test execution does not stop main.Run(["-o", "png", TEST_DATA_DIR]) # Check that the right info message is shown to the user assert ("Unable to determine Graphviz supported output formats." in capsys.readouterr().out) # Check that pyreverse actually made the call to create the diagram and we exit cleanly mock_writer.DiagramWriter().write.assert_called_once() assert wrapped_sysexit.value.code == 0
def test_graphviz_unsupported_image_format(capsys): """Test that Graphviz is used if the image format is supported.""" with pytest.raises(SystemExit) as wrapped_sysexit: # we have to catch the SystemExit so the test execution does not stop main.Run(["-o", "somethingElse", TEST_DATA_DIR]) # Check that the right info messages are shown to the user stdout = capsys.readouterr().out assert ( "Format somethingElse is not supported natively. Pyreverse will try to generate it using Graphviz..." in stdout) assert "Format somethingElse is not supported by Graphviz. It supports:" in stdout # Check that we exited with the expected error code assert wrapped_sysexit.value.code == 32
def test_class_command( mock_writer: mock.MagicMock, # pylint: disable=unused-argument ) -> None: """Regression test for the --class option. Make sure that we append multiple --class arguments to one option destination. """ runner = main.Run([ "--class", "data.clientmodule_test.Ancestor", "--class", "data.property_pattern.PropertyPatterns", TEST_DATA_DIR, ]) assert "data.clientmodule_test.Ancestor" in runner.config.classes assert "data.property_pattern.PropertyPatterns" in runner.config.classes
def test_command_line_arguments_defaults(arg: str, expected_default: Any) -> None: """Test that the default arguments of all options are correct.""" run = main.Run([TEST_DATA_DIR]) assert getattr(run.config, arg) == expected_default