Skip to content

Commit

Permalink
Add 'notest' parameter to skip tests when building ODS file
Browse files Browse the repository at this point in the history
  • Loading branch information
jferard committed Nov 24, 2024
1 parent d1d518b commit 36d3101
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 5 additions & 2 deletions py4lo/commands/update_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
class UpdateCommand(Command):
@staticmethod
def create_executor(args: List[str], provider: PropertiesProvider) -> CommandExecutor:
test_executor = TestCommand.create_executor(args, provider)
if "notest" in args:
test_executor = None
else:
test_executor = TestCommand.create_executor(args, provider)
logger = provider.get_logger()
update_command = UpdateCommand.create(logger, provider)
return CommandExecutor(logger, update_command, test_executor)
Expand Down Expand Up @@ -65,7 +68,7 @@ def __init__(self, logger: Logger, helper: OdsUpdaterHelper,
self._python_version = python_version
self._add_readme_callback = add_readme_callback

def execute(self, status: int) -> Tuple[Any, ...]:
def execute(self, status: int = 0) -> Tuple[Any, ...]:
self._logger.info(
"Update. Generating '%s' (source: %s) for Python '%s'",
self._dest_ods_file,
Expand Down
6 changes: 3 additions & 3 deletions py4lo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def get_args(argv: List[str] = sys.argv[1:]) -> argparse.Namespace:
default="py4lo.toml", type=str)
parser.add_argument("command",
help=commands.get_help_message(), type=str)
parser.add_argument("parameter", nargs="*",
help="command parameter")
parser.add_argument("parameters", nargs="*",
help="command parameters")
return parser.parse_args(argv)


Expand All @@ -44,7 +44,7 @@ def main(factory: PropertiesProviderFactory, argv: List[str] = sys.argv[1:]):
logger.debug("Log Level is: %s", logger.getEffectiveLevel())
logger.debug("Command line arguments are: %s", args)

command = commands.get(args.command, args.parameter,
command = commands.get(args.command, args.parameters,
provider)
logger.debug("Command is %s", command)

Expand Down
4 changes: 4 additions & 0 deletions test/py4lo/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def test(self):
factory = mock.MagicMock()
main.main(factory, ["py4lo", "help"])

def test_args(self):
args = main.get_args(["run", "notest"])
self.assertEqual("run", args.command)
self.assertEqual(["notest"], args.parameters)

if __name__ == '__main__':
unittest.main()

0 comments on commit 36d3101

Please sign in to comment.