Commits

Konstantine Rybnikov committed 411202c Draft

some initial boilerplate

Comments (0)

Files changed (8)

parsehelp/__init__.py

+# -*- coding: utf-8 -*-
+
+from parsehelp.main import parse_help

parsehelp/core/__init__.py

+# -*- coding: utf-8 -*-

parsehelp/core/test.py

+# -*- coding: utf-8 -*-
+
+from os.path import abspath, dirname, join
+import unittest
+
+TESTDATA = (
+    join(dirname(dirname(dirname(abspath(__file__)))),
+         'tests',
+         'testdata'))
+
+
+class BaseTestCase(unittest.TestCase):
+    def assert_equals(self, *args, **kw):
+        return self.assertEquals(*args, **kw)
+
+    def assert_in(self, *args, **kw):
+        return self.assertIn(*args, **kw)
+
+    def assert_is(self, *args, **kw):
+        return self.assertIs(*args, **kw)

parsehelp/main.py

+# -*- coding: utf-8 -*-
+
+
+def parse_help(text):
+    return {}
+nose
+mock
+mockstar

tests/__init__.py

+# -*- coding: utf-8 -*-

tests/parsehelp_test.py

+# -*- coding: utf-8 -*-
+
+from os.path import join
+from parsehelp.core.test import BaseTestCase
+from parsehelp.core.test import TESTDATA
+from parsehelp import parse_help
+
+
+class TestParseHelp(BaseTestCase):
+    def assert_help(self, help_file, data):
+        help_file_contents = ''
+        with open(help_file) as f:
+            help_file_contents = f.read()
+        result = parse_help(help_file_contents)
+        self.assert_equals(data, result)
+
+    def get_help_contents(self, filename):
+        rv = u''
+        help_file = join(TESTDATA, 'helps', filename + '.txt')
+        with open(help_file) as f:
+            rv = f.read()
+        return rv
+
+    def test_should_parse_help_from_pip(self):
+        # do
+        result = parse_help(self.get_help_contents('pip'))
+
+        self.assert_is(type(result), dict)
+        self.assert_in('options', result)
+        # self.assert_help(
+        #     result,
+        #     {'options':
+        #          [{'keys': ['--version'],
+        #            'description': u"show program's version number and exit"}]})

tests/testdata/helps/pip.txt

+Usage: pip COMMAND [OPTIONS]
+
+Options:
+  --version             show program's version number and exit
+  -h, --help            Show help
+  -E DIR, --environment=DIR
+                        virtualenv environment to run pip in (either give the
+                        interpreter or the environment base directory)
+  -s, --enable-site-packages
+                        Include site-packages in virtualenv if one is to be
+                        created. Ignored if --environment is not used or the
+                        virtualenv already exists.
+  -v, --verbose         Give more output
+  -q, --quiet           Give less output
+  --log=FILENAME        Log file where a complete (maximum verbosity) record
+                        will be kept
+  --proxy=PROXY         Specify a proxy in the form
+                        user:passwd@proxy.server:port. Note that the
+                        user:password@ is optional and required only if you
+                        are behind an authenticated proxy.  If you provide
+                        user@proxy.server:port then you will be prompted for a
+                        password.
+  --timeout=SECONDS, --default-timeout=SECONDS
+                        Set the socket timeout (default 15 seconds)
+
+Commands available:
+  bundle: Create pybundles (archives containing multiple packages)
+  freeze: Output all currently installed packages (exact versions) to stdout
+  help: Show available commands
+  install: Install packages
+  search: Search PyPI
+  uninstall: Uninstall packages
+  unzip: Unzip individual packages
+  zip: Zip individual packages