Created
September 14, 2016 21:25
-
-
Save con-f-use/bac4c22e019497ab7380d05297bbc748 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Let's call this file 'mymodule.py' | |
# When run from the 'shell application' created by setuptools, | |
#+only doctests for `main()` get run, while `to_be_tested()` is | |
#+ignored `mymoduleapp -test`. | |
# Testing for both functions works, when run direcly as shell | |
# script, e.g. as `./mymodule.py --test` | |
# Used python version: Python 2.7.12 (setuptools 20.7.0) | |
import sys | |
def to_be_tested(): | |
'''\ | |
>>> to_be_tested() | |
2 | |
''' | |
return 1 # Would fail, but doesn't get tested | |
def main(): | |
if '--test' in sys.argv: # Test all functions above | |
import doctest | |
doctest.testmod(verbose=True) # Doesn't work | |
exit(0) | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from setuptools import setup | |
setup( | |
name = 'mymodule', | |
version = 1, | |
author_email = '[email protected]', | |
py_modules = ['mymodule'], | |
entry_points=''' | |
[console_scripts] | |
mymoduleapp=mymodule:main | |
''' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment