UNKNOWN
Project description
Google Application Utilities for Python
=======================================
This project is a small collection of utilities for building Python
applications. It includes some of the same set of utilities used to build and
run internal Python apps at Google.
Features:
* Simple application startup integrated with python-gflags.
* Subcommands for command-line applications.
* Option to drop into pdb on uncaught exceptions.
* Helper functions for dealing with files.
* High-level profiling tools.
* Timezone-aware wrappers for datetime.datetime classes.
* Improved TestCase with the same methods as unittest2, plus helpful flags for
test startup.
* google_test setuptools command for running tests.
* Helper module for creating application stubs.
Installation
============
To install the package, simply run:
python setup.py install
Google-Style Tests
==================
Google-style tests (those run with basetest.main()) differ from setuptools-style
tests in that test modules are designed to be run as __main__. Setting up your
project to use Google-style tests is easy:
1. Create one or more test modules named '*_test.py' in a directory. Each test
module should have a main block that runs basetest.main():
# In tests/my_test.py
from google.apputils import basetest
class MyTest(basetest.TestCase):
def testSomething(self):
self.assertTrue('my test')
if __name__ == '__main__':
basetest.main()
2. Add a setup requirement on google-apputils and set the test_dir option:
# In setup.py
setup(
...
setup_requires = ['google-apputils>=0.2'],
test_dir = 'tests',
)
3. Run your tests:
python setup.py google_test
Google-Style Stub Scripts
=========================
Google-style binaries (run with app.run()) are intended to be executed directly
at the top level, so you should not use a setuptools console_script entry point
to point at your main(). You can use distutils-style scripts if you want.
Another alternative is to use google.apputils.run_script_module, which is a
handy wrapper to execute a module directly as if it were a script:
1. Create a module like 'stubs.py' in your project:
# In my/stubs.py
from google.apputils import run_script_module
def RunMyScript():
import my.script
run_script_module.RunScriptModule(my.script)
def RunMyOtherScript():
import my.other_script
run_script_module.RunScriptModule(my.other_script)
2. Set up entry points in setup.py that point to the functions in your stubs
module:
# In setup.py
setup(
...
entry_points = {
'console_scripts': [
'my_script = my.stubs:RunMyScript',
'my_other_script = my.stubs.RunMyOtherScript',
],
},
)
There are also useful flags you can pass to your scripts to help you debug your
binaries; run your binary with --helpstub to see the full list.
=======================================
This project is a small collection of utilities for building Python
applications. It includes some of the same set of utilities used to build and
run internal Python apps at Google.
Features:
* Simple application startup integrated with python-gflags.
* Subcommands for command-line applications.
* Option to drop into pdb on uncaught exceptions.
* Helper functions for dealing with files.
* High-level profiling tools.
* Timezone-aware wrappers for datetime.datetime classes.
* Improved TestCase with the same methods as unittest2, plus helpful flags for
test startup.
* google_test setuptools command for running tests.
* Helper module for creating application stubs.
Installation
============
To install the package, simply run:
python setup.py install
Google-Style Tests
==================
Google-style tests (those run with basetest.main()) differ from setuptools-style
tests in that test modules are designed to be run as __main__. Setting up your
project to use Google-style tests is easy:
1. Create one or more test modules named '*_test.py' in a directory. Each test
module should have a main block that runs basetest.main():
# In tests/my_test.py
from google.apputils import basetest
class MyTest(basetest.TestCase):
def testSomething(self):
self.assertTrue('my test')
if __name__ == '__main__':
basetest.main()
2. Add a setup requirement on google-apputils and set the test_dir option:
# In setup.py
setup(
...
setup_requires = ['google-apputils>=0.2'],
test_dir = 'tests',
)
3. Run your tests:
python setup.py google_test
Google-Style Stub Scripts
=========================
Google-style binaries (run with app.run()) are intended to be executed directly
at the top level, so you should not use a setuptools console_script entry point
to point at your main(). You can use distutils-style scripts if you want.
Another alternative is to use google.apputils.run_script_module, which is a
handy wrapper to execute a module directly as if it were a script:
1. Create a module like 'stubs.py' in your project:
# In my/stubs.py
from google.apputils import run_script_module
def RunMyScript():
import my.script
run_script_module.RunScriptModule(my.script)
def RunMyOtherScript():
import my.other_script
run_script_module.RunScriptModule(my.other_script)
2. Set up entry points in setup.py that point to the functions in your stubs
module:
# In setup.py
setup(
...
entry_points = {
'console_scripts': [
'my_script = my.stubs:RunMyScript',
'my_other_script = my.stubs.RunMyOtherScript',
],
},
)
There are also useful flags you can pass to your scripts to help you debug your
binaries; run your binary with --helpstub to see the full list.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
google-apputils-0.4.1.zip
(59.3 kB
view details)
google-apputils-0.4.1.tar.gz
(48.1 kB
view details)
Built Distribution
google_apputils-0.4.1-py2.7.egg
(118.2 kB
view details)
File details
Details for the file google-apputils-0.4.1.zip
.
File metadata
- Download URL: google-apputils-0.4.1.zip
- Upload date:
- Size: 59.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 821cb2756e0719199f6bd5c2077b8b91db118517f0fe1aa88765f8e5c32a95df |
|
MD5 | 262adc45be153bc005f0e3185aa526e6 |
|
BLAKE2b-256 | 75e45d05e808d9270695c3d01ee9e7757871843a6dda3d1268b2cceced63de76 |
Provenance
File details
Details for the file google-apputils-0.4.1.tar.gz
.
File metadata
- Download URL: google-apputils-0.4.1.tar.gz
- Upload date:
- Size: 48.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b48bb6c20a94faaeaaf15e22603fd603977e8b8872269fdc784e49d70a9baeb |
|
MD5 | 049ed237ad43afdc0931c2e5a0c50f3a |
|
BLAKE2b-256 | 8b8a7111b3bb0d825b1ac4e54cc0f092936e05238703fee1e2b890e218108b4f |
Provenance
File details
Details for the file google_apputils-0.4.1-py2.7.egg
.
File metadata
- Download URL: google_apputils-0.4.1-py2.7.egg
- Upload date:
- Size: 118.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f30d6782e563336b7d0b52f4ef3eda809b2ba213d0d2e63034dfbfb422e6ae69 |
|
MD5 | c72daa9918fe731bf575da0e9958af47 |
|
BLAKE2b-256 | 40e2daf5d55b894c869eba40d6f462b1faa618bd7c8a503ab0cbdd7476dce2bb |