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

Run examples as part of test run #84

Open
mjallday opened this issue Jan 22, 2014 · 2 comments
Open

Run examples as part of test run #84

mjallday opened this issue Jan 22, 2014 · 2 comments

Comments

@mjallday
Copy link
Contributor

It's too easy to break the examples and not know about it.

@julianpistorius
Copy link
Contributor

I've run into this problem with the examples before. I'll have a look at it. Any suggestions on how the examples could be run as part of the test suite?

@mjallday
Copy link
Contributor Author

We can either enumerate all the files in the directory and run them then check for return code == 0 or rewrite the examples to be importable (e.g. if __name__ == 'main': run_example()).

I think the first is probably less work so doing it that way would be easier.

On the test side I think something like

import subprocess, sys
class ExampleTests(TestCase):
    def test_examples_run(self):
         for example_file_name in example_dir_files:
              self.assertEqual(subprocess.call( sys.executeable + " " + example_file_name, shell=True), 0)

this is probably a pretty naive implementation but it has the general idea right.

hat tip to @coderanger for the sys.executable move.

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

No branches or pull requests

2 participants