[tor-commits] [stem/master] Expanding doctest to cover the conf module
atagar at torproject.org
atagar at torproject.org
Sun Oct 27 18:13:00 UTC 2013
commit f3d6063b761172eafd7ce027e727eeb8b5bc79a4
Author: Damian Johnson <atagar at torproject.org>
Date: Sun Oct 27 10:58:56 2013 -0700
Expanding doctest to cover the conf module
Including a small bit of the conf module with our tests. We're skipping the
part where we print CONFIG because an actual interpretor doesn't do a pretty
print, so we'd need to make our example less readable to be correct.
---
stem/util/conf.py | 4 ++--
test/unit/doctest.py | 9 +++++++--
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/stem/util/conf.py b/stem/util/conf.py
index 817c406..8a4f361 100644
--- a/stem/util/conf.py
+++ b/stem/util/conf.py
@@ -106,10 +106,10 @@ Now lets say our user has the following configuration file...
::
- >>> from from stem.util import conf
+ >>> from stem.util import conf
>>> our_config = conf.get_config("ssh_login")
>>> our_config.load("/home/atagar/user_config")
- >>> print CONFIG
+ >>> print CONFIG # doctest: +SKIP
{
"username": "waddle_doo",
"password": "jabberwocky",
diff --git a/test/unit/doctest.py b/test/unit/doctest.py
index 9735dbd..ac9f430 100644
--- a/test/unit/doctest.py
+++ b/test/unit/doctest.py
@@ -37,10 +37,15 @@ class TestDocumentation(unittest.TestCase):
test_run = None
if path.endswith('/stem/util/conf.py'):
- pass # too much context to easily test
+ with patch('stem.util.conf.get_config') as get_config_mock:
+ config = Mock()
+ config.load.return_value = None
+ get_config_mock.return_value = config
+
+ test_run = doctest.testfile(path, **args)
elif path.endswith('/stem/descriptor/router_status_entry.py'):
args['globs'] = {
- '_base64_to_hex': stem.descriptor.router_status_entry._base64_to_hex
+ '_base64_to_hex': stem.descriptor.router_status_entry._base64_to_hex,
}
test_run = doctest.testfile(path, **args)
More information about the tor-commits
mailing list