question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

test suit needs to have jb in $PATH

See original GitHub issue

Test suit is full with lines like

https://github.com/executablebooks/jupyter-book/blob/a3dea447361253199940cf98ea11f413b9fa4194/tests/test_clean.py#L26

the problem with this, is that its assume that jb its on your path, and probably does not make any check to see if its the one you should be testing. this means that if i’m working on a virtual environment, i need to activate the virtual environment. so

~/code/jupyter-book >>> python3 -m venv venv
~/code/jupyter-book >>> ./venv/bin/python -m pip install  .[testing,code_style,sphinx] 
~/code/jupyter-book >>> ./venv/bin/pytest tests

will fail, with

E               FileNotFoundError: [Errno 2] No such file or directory: 'jb'

because jb is not in the path. you actually need to activate the venv

~/code/jupyter-book >>> source ./venv/bin/activate 
~/code/jupyter-book >>> ./venv/bin/pytest tests

that add an extra step that should be necesary


a much cleaner way of testing click apps, is use the CliRunner that comes with click. that way the line

run(f"jb clean {path}".split())

can be written like

from click.testing import CliRunner
from jupyter_book.commands import main
 
CliRunner.invoke(main, ["clean", path])

and this can be run without really activating the venv…

if this is ok, i can submit the PR, i just dont wanna do that work if you folks are actively not using clirunner

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisjsewellcommented, Aug 20, 2020

Oh indeed, I didn’t write any of this test infrastucture, but was intending to take a hammer to it at some point lol. I’ve used CliRunner plenty e.g. in https://github.com/executablebooks/jupyter-cache/blob/master/tests/test_cli.py

FYI though, you may notice I just added a tox.ini to the repo (9daee14c2cf5e18aa475cee337a9389278682b82), and using that you don’t have to activate any virtual envs (it does it for you 😉)

But yeh, I wouldn’t say no to a PR 😄

0reactions
aleivagcommented, Aug 28, 2020

@chrisjsewell seems like it does solve the issue… Thanks!!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I configure PyCharm to run py.test tests?
Please go to File | Settings | Tools | Python Integrated Tools and change the default test runner to py.test. Then you'll get...
Read more >
Integrated Tests Are A Scam - The Code Whisperer
If you're not careful, accumulating integrated tests will gradually suffocate your code base, driving you to a place where you have to decide ......
Read more >
Automated Regression Testing: Challenges, Process And Steps
To start automating regression test cases, the very first thing that you need to do is to get the regression test cases identified...
Read more >
Create test plans and test suites - Azure - Microsoft Learn
Learn about Test tools. Create test plans in Azure Test Plans and Azure DevOps Server to make sure each of the deliverables meets...
Read more >
Frequently Asked Questions - JUnit 5
What CLASSPATH settings are needed to run JUnit? Why do I get a NoClassDefFoundError when trying to test JUnit or run the samples?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found