Skip to content
This repository has been archived by the owner on Dec 23, 2018. It is now read-only.

Test functions instead of cells #26

Open
pylang opened this issue Nov 23, 2017 · 4 comments
Open

Test functions instead of cells #26

pylang opened this issue Nov 23, 2017 · 4 comments

Comments

@pylang
Copy link

pylang commented Nov 23, 2017

Hi. Is it possible to read tests from regular functions and class names? This would alleviate coding each test to a separate cell and allow the use of traditional unittests.

@zonca
Copy link
Owner

zonca commented Nov 24, 2017 via email

@pylang
Copy link
Author

pylang commented Nov 24, 2017

And I suspect easier to code. For example, you can parse the notebook cell source keys from json, access the cell name and remaining cell code.

I don't mind this idea of running tests in cells. However, using functions helps maintain local scopes. It also does not compel the user to defect from a standard, functional way of writing tests. Consider writing a simple test function:

test_foo():
     assert foo() == expected

Someone familiar with unit tests in python understands what that is - a test on some object called foo. This test can be run in jupyter, or copied/pasted into a module and run by many test runners, i.e. unittest (with some modification), nose and pytest. Here, the tests are restricted to notebook cells.

Supporting tests as cells is fine and interesting. I would only recommend extending this plugin to support an extant convention of writing traditional tests. This improvement might be promising in attacking a bigger issue - that is not being able to run pytest inside a notebook

@zonca
Copy link
Owner

zonca commented Nov 24, 2017 via email

@pylang
Copy link
Author

pylang commented Nov 25, 2017

Thanks. I cannot contribute a pull request at the moment, but perhaps I may in the future. I admit the learning curve is steep to make a contribution at the moment. In the meantime, those interested on continuing this idea are welcome.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants