Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Unit Test for Executable #45

Merged
merged 4 commits into from Dec 9, 2019
Merged

Conversation

lkiesow
Copy link
Contributor

@lkiesow lkiesow commented Nov 27, 2019

This patch adds a simple unit test for the executable.

This patch adds a simple unit test for the executable.
Copy link
Contributor

@shaardie shaardie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this brakes running the tests with

$ python setup.py test
running test
running egg_info
writing sentinel5dl.egg-info/PKG-INFO
writing dependency_links to sentinel5dl.egg-info/dependency_links.txt
writing entry points to sentinel5dl.egg-info/entry_points.txt
writing requirements to sentinel5dl.egg-info/requires.txt
writing top-level names to sentinel5dl.egg-info/top_level.txt
reading manifest file 'sentinel5dl.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'sentinel5dl.egg-info/SOURCES.txt'
running build_ext
test (tests.__main__.TestExecutable)
Test search and download. ... usage: setup.py [-h] [--polygon POLYGON] [--product PRODUCT] [--level {L1B,L2}] [--begin-ts BEGIN_TS] [--end-ts END_TS] [--use-certifi]
setup.py: error: unrecognized arguments: test
ERROR
test (tests.__main__.TestSentinel5dl)
Test search and download. ... ok

======================================================================
ERROR: test (tests.__main__.TestExecutable)
Test search and download.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sven/devel/emission-api/sentinel5dl/tests/__main__.py", line 106, in test
    executable.main()
  File "/home/sven/devel/emission-api/sentinel5dl/sentinel5dl/__main__.py", line 153, in main
    args = parser.parse_args()
  File "/usr/lib/python3.8/argparse.py", line 1771, in parse_args
    self.error(msg % ' '.join(argv))
  File "/usr/lib/python3.8/argparse.py", line 2520, in error
    self.exit(2, _('%(prog)s: error: %(message)s\n') % args)
  File "/usr/lib/python3.8/argparse.py", line 2507, in exit
    _sys.exit(status)
SystemExit: 2

----------------------------------------------------------------------
Ran 2 tests in 0.005s

FAILED (errors=1)
Test failed: <unittest.runner.TextTestResult run=2 errors=1 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=2 errors=1 failures=0>

`argparse` is trying to parse the command line arguments while testing the
binary. This patch simply clears `sys.argv` to circumvent that.
Copy link
Contributor

@shaardie shaardie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added fixed for the problems I saw. Now I am happy. You could freely merge this.

@lkiesow lkiesow merged commit 31aa31a into emissions-api:master Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants