Skip to content

Commit

Permalink
Merge branch 'mr/leger/1-class-main-from-main-py-does-not-use-its-nam…
Browse files Browse the repository at this point in the history
…e-parameter' into 'master'

Resolve "Class `Main` from `main.py` does not use its name parameter"

Closes #1

See merge request it/e3-core!5
  • Loading branch information
grouigrokon committed Jul 16, 2024
2 parents ffaa8c7 + 756606c commit 3deba8c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ __pycache__
*.egg-info
/htmlcov
/.tox
/venv*
/docs/_build
docs/build
docs/source/requirement_coverage.rst
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Version 22.7.0 (2024-??-??) *NOT RELEASED YET*
* Take `main.Main` name's argument as the arguments parser's prog name
* Add DLL closure check to Anod class

* Add git_shallow_fetch_since to checkout.py

# Version 22.6.0 (2024-06-19)
Expand Down
8 changes: 4 additions & 4 deletions src/e3/main.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""Main program initialization.
This package provides a class called Main used to initialize a python script
invoked from command line. The main goal is to ensure consistency in term of
invoked from command line. The main goal is to ensure consistency in terms of
interface, documentation and logging activities for all scripts using e3.
The script will support by default the following switches::
-v|--verbose to enable verbose mode (a console logger is added)
-h|--help display command line help
--log-file FILE
to redirect logs to a given file (this is independent from
verbose option
to redirect logs to a given file (this is independent of
verbose option)
--console-logs
disable color, progress bars, and redirect as much as
possible to stdout, starting lines with the given prefix
Expand Down Expand Up @@ -86,7 +86,7 @@ def __init__(
self.name = "unknown"

if argument_parser is None:
argument_parser = ArgumentParser()
argument_parser = ArgumentParser(prog=self.name)

e3.log.add_logging_argument_group(argument_parser, default_level=logging.INFO)

Expand Down
8 changes: 4 additions & 4 deletions tests/tests_e3/main/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_mainprog():
)
)
p = e3.os.process.Run([sys.executable, "mymain.py", "--nocolor"])
assert "mymain" in p.out
assert "testmain" in p.out


def test_modules_logging_limitations():
Expand Down Expand Up @@ -112,15 +112,15 @@ def test_mainprog_with_console_logs():
)

assert re.search(
r"^mymain:.*:.*: DEBUG this is an info line\r?\n"
"mymain:.*:.* DEBUG this is a debug line",
r"^mymain:.*:.*: DEBUG +this is an info line\r?\n"
"mymain:.*:.* DEBUG +this is a debug line",
p.out,
re.MULTILINE,
)


@pytest.mark.skipif(
sys.platform not in ("win32"),
sys.platform not in ("win32",),
reason="This test is only for windows platform",
)
def test_x86_64_windows_default():
Expand Down

0 comments on commit 3deba8c

Please sign in to comment.