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 cli tests #37

Closed
steven-esser opened this issue Dec 19, 2017 · 3 comments
Closed

Add cli tests #37

steven-esser opened this issue Dec 19, 2017 · 3 comments
Assignees

Comments

@steven-esser
Copy link
Contributor

Use the scancode cli.py tests as a model. We mainly want to verify correct cli output in certain scenarios.

johnmhoran added a commit that referenced this issue Jan 19, 2018
Signed-off-by: John M. Horan <johnmhoran@gmail.com>
@johnmhoran
Copy link
Member

@MaJuRG Please let me know what you think about my approach in this initial commit. I’ve added three cli tests:

  • test_json_output_option_selected()
  • test_csv_output_option_selected()
  • test_usage_and_help()

To support the cli tests, I’ve copied and slightly modified three functions from scancode/cli_test_utils.py:

  • run_scan_click()
  • check_json_scan()
  • _load_json_result()

I’ve left my comments intact to help explain what I’ve done and pose open questions.

All 130 tests pass, but the return in run_scan_click() raises a warning:

tests/test_cli.py::TestCLI::test_csv_output_option_selected
  C:\code\nexb\dev\deltacode\tests\test_cli.py:62: Warning: Click detected the use of the unicode_literals __future__ import.  This is heavily discouraged because it can introduce subtle bugs in your code.  You should instead use explicit u"" literals for your unicode strings.  For more information see http://click.pocoo.org/python3/
    return runner.invoke(cli.cli, options, catch_exceptions=catch_exceptions)

-- Docs: http://doc.pytest.org/en/latest/warnings.html  

johnmhoran added a commit that referenced this issue Jan 19, 2018
  * Removed and replaced ScanCode-based functions and tests.

Signed-off-by: John M. Horan <johnmhoran@gmail.com>
@johnmhoran
Copy link
Member

@MaJuRG Is this closer to what you have in mind?

I'm not sure my approach on this line is optimal -- I use a list comprehension but don't really want a list, so I need to grab the item at index 0, which seems a bit convoluted.

I have an idea for a few more tests but welcome your suggestions -- including how we might test for the post-refactoring issues you've run into (you mention them in issue #38).

johnmhoran added a commit that referenced this issue Jan 20, 2018
Signed-off-by: John M. Horan <johnmhoran@gmail.com>
steven-esser added a commit that referenced this issue Jan 20, 2018
@steven-esser
Copy link
Contributor Author

#44 handles the start of this. Closing.

arnav-mandal1234 pushed a commit to arnav-mandal1234/deltacode that referenced this issue Mar 16, 2023
    * Replace all references to `tmp` with `venv`

Signed-off-by: Jono Yang <jyang@nexb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants