/usr/share/pyshared/nose_testconfig-0.9.egg-info/PKG-INFO is in python-nose-testconfig 0.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | Metadata-Version: 1.1
Name: nose-testconfig
Version: 0.9
Summary: Test Configuration plugin for nosetests.
Home-page: UNKNOWN
Author: Jesse Noller
Author-email: jnoller@gmail.com
License: Apache License, Version 2.0
Description: ==========
testconfig
==========
* Project hosting: <http://bitbucket.org/jnoller/nose-testconfig/>
.. contents::
About
------------------
Written by Jesse Noller
Licensed under the Apache Software License, 2.0
You can install it with ``pip install nose-testconfig``
What It Does
------------
nose-testconfig is a plugin to the nose test framework which provides a
faculty for passing test-specific (or test-run specific) configuration data
to the tests being executed.
Currently configuration files in the following formats are supported:
- YAML (via `PyYAML <http://pypi.python.org/pypi/PyYAML/>`_)
- INI (via `ConfigParser <http://docs.python.org/lib/module-ConfigParser.html>`_)
- Pure Python (via Exec)
- JSON (via `JSON <http://docs.python.org/library/json.html>`_)
The plugin is ``meant`` to be flexible, ergo the support of exec'ing arbitrary
python files as configuration files with no checks. The default format is
assumed to be ConfigParser ini-style format.
The plugin provides a method of overriding certain parameters from the command
line (assuming that the main "config" object is a dict) and can easily have
additional parsers added to it.
A configuration file may not be provided. In this case, the config object is an
emtpy dict. Any command line "overriding" paramters will be added to the dict.
Test Usage
----------
For now (until something better comes along) tests can import the "config"
singleton from testconfig::
from testconfig import config
By default, YAML files parse into a nested dictionary, and ConfigParser ini
files are also collapsed into a nested dictionary for foo[bar][baz] style
access. Tests can obviously access configuration data by referencing the
relevant dictionary keys::
from testconfig import config
def test_foo():
target_server_ip = config['servers']['webapp_ip']
``Warning``: Given this is just a dictionary singleton, tests can easily write
into the configuration. This means that your tests can write into the config
space and possibly alter it. This also means that threaded access into the
configuration can be interesting.
When using pure python configuration - obviously the "sky is the the limit" -
given that the configuration is loaded via an exec, you could potentially
modify nose, the plugin, etc. However, if you do not export a config{} dict
as part of your python code, you obviously won't be able to import the
config object from testconfig.
When using YAML-style configuration, you get a lot of the power of pure python
without the danger of unprotected exec() - you can obviously use the pyaml
python-specific objects and all of the other YAML creamy goodness.
Defining a configuration file
-----------------------------
Simple ConfigParser style::
[myapp_servers]
main_server = 10.1.1.1
secondary_server = 10.1.1.2
So your tests access the config options like this::
from testconfig import config
def test_foo():
main_server = config['myapp_servers']['main_server']
YAML style configuration::
myapp:
servers:
main_server: 10.1.1.1
secondary_server: 10.1.1.2
And your tests can access it thus::
from testconfig import config
def test_foo():
main_server = config['myapp']['servers']['main_server']
Python configuration file::
import socket
global config
config = {}
possible_main_servers = ['10.1.1.1', '10.1.1.2']
for srv in possible_main_servers:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((srv, 80))
except:
continue
s.close()
config['main_server'] = srv
break
And lo, the config is thus::
from testconfig import config
def test_foo():
main_server = config['main_server']
If you need to put python code into your configuration, you either need to use
the python-config file faculties, or you need to use the !!python tags within
PyYAML/YAML - raw ini files no longer have any sort of eval magic.
Command line options
--------------------
After it is installed, the plugin adds the following command line flags to
nosetests::
--tc-file=TESTCONFIG Configuration file to parse and pass to tests
[NOSE_TEST_CONFIG_FILE]
--tc-format=TESTCONFIGFORMAT Test config file format, default is
configparser ini format
[NOSE_TEST_CONFIG_FILE_FORMAT]
--tc=OVERRIDES Option:Value specific overrides.
--tc-exact Optional: Do not explode periods in override keys to
individual keys within the config dict, instead treat
them as config[my.toplevel.key] ala sqlalchemy.url in
pylons.
Passing in an INI configuration file::
$ nosetests -s --tc-file example_cfg.ini
Passing in a YAML configuration file::
$ nosetests -s --tc-file example_cfg.yaml --tc-format yaml
Passing in a Python configuration file::
$ nosetests -s --tc-file example_cfg.py --tc-format python
Overriding a configuration value on the command line::
$ nosetests -s --tc-file example_cfg.ini --tc=myvalue.sub:bar
Passing paramters on the command line without specifying a configuration file::
$ nosetests -s --tc=myvalue.sub2:baz
Overriding multiple key:value pairs::
$ nosetests -s --tc-file example_cfg.ini --tc=myvalue.sub:bar \
--tc=myvalue.sub2:baz --tc=myvalue.sub3:bar3
``Warning``: When using the --tc= flag, you can pass it in as many times as
you want to override as many keys/values as needed. The format is in
``parent.child.child = value`` format - the periods are translated into keys
within the config dict, for example::
myvalue.sub2:baz = config[myvalue][sub2] = baz
You can override the explosion of the periods by passing in the --tc-exact
argument on the command line.
Special environment variables
-----------------------------
If you have a test which performs an import like this::
from testconfig import config
Then you know you can not run your test through a tool like pychecker as
pychecker executes the file you are scanning, an warning is thrown and any use
of the config dict will cause an exception.
To work around this, I've added four environment variable checks which, if
set will cause a given configuration file to be auto-loaded into the module
and the config dict will be populated. These are::
NOSE_TESTCONFIG_AUTOLOAD_YAML
NOSE_TESTCONFIG_AUTOLOAD_INI
NOSE_TESTCONFIG_AUTOLOAD_PYTHON
NOSE_TESTCONFIG_AUTOLOAD_JSON
Setting one of these to ``full path`` of the target configuration file in your
environment/editor/etc will make it auto load that configuration file. You can
now run it through pychecker. Much success was had!
For example, I set NOSE_TESTCONFIG_AUTOLOAD_YAML to /Users/jesse/foo.yaml
within textmate. I can now use pychecker via control-shift-v with much win.
Changes & News
--------------
0.9:
* Python 3 compatible
* fix loading of data files when environment variables
NOSE_TESTCONFIG_AUTOLOAD_* are specified.
* added tests
0.8:
* unicode support for config files (gjednaszewski/dhellmann)
* colons are allowed in user's arguments, such as --tc url:127.0.0.1:5000 (aconrad)
* config file is not longer required, --tc option may be provided alone (aconrad)
0.7:
* Add ability to handle json format.
0.6:
* Add in checking for 3 different environment variables corresponding to
the supported config file types. Setting one of these to the full path
to a given configuration file will force nose-testconfig to autoload that
file. Handy if you want to run a test which imports the testconfig module
through something like pychecker (or run it from the command line).
0.5:
* Fix a bug in the python config file parsing reported by Christopher Hesse
0.4:
* Per feedback from Kumar and others, the eval()'ing of ini-file values
has been removed: allowing arbitrary python in the values was more
annoying less standard then was worth it.
* Added the --tc-exact command line flag, to block the exploding of
name.name values into dicts-within-dicts
* Updated the docs to parse right.
0.3:
Fix documentation examples per Kumar's feedback.
0.2:
Fix pypi packaging issues
0.1:
Initial release. May contain bits of glass.
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Topic :: Software Development :: Testing
|