Skip to content

Commit

Permalink
Enable doctests in unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
glennmatthews committed Jul 12, 2016
1 parent f05758d commit 26c8587
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
18 changes: 10 additions & 8 deletions COT/cli.py
Expand Up @@ -164,10 +164,12 @@ def fill_usage(self, subcommand, usage_list):
::
>>> fill_usage('add-file', ["FILE PACKAGE [-o OUTPUT] [-f FILE_ID]"])
>>> print(CLI(50).fill_usage('add-file',
... ["FILE PACKAGE [-o OUTPUT] [-f FILE_ID]"]))
<BLANKLINE>
cot add-file --help
cot add-file FILE PACKAGE [-o OUTPUT]
[-f FILE_ID]
cot <opts> add-file FILE PACKAGE [-o OUTPUT]
[-f FILE_ID]
:param str subcommand: Subcommand name/keyword
:param list usage_list: List of usage strings for this subcommand.
Expand Down Expand Up @@ -230,7 +232,7 @@ def fill_examples(self, example_list):
::
>>> fill_examples([
>>> print(CLI(70).fill_examples([
... ("Deploy to vSphere/ESXi server 192.0.2.100 with credentials"
... " admin/admin, creating a VM named 'test_vm' from foo.ova.",
... 'cot deploy foo.ova esxi 192.0.2.100 -u admin -p admin'
Expand All @@ -239,18 +241,18 @@ def fill_examples(self, example_list):
... " admin (prompting the user to input a password at runtime),"
... " creating a VM based on profile '1CPU-2.5GB' in foo.ova.",
... 'cot deploy foo.ova esxi 192.0.2.100 -u admin -c 1CPU-2.5GB')
... ])
... ]))
Examples:
Deploy to vSphere/ESXi server 192.0.2.100 with credentials
admin/admin, creating a VM named 'test_vm' from foo.ova.
<BLANKLINE>
cot deploy foo.ova esxi 192.0.2.100 -u admin -p admin \
-n test_vm
<BLANKLINE>
Deploy to vSphere/ESXi server 192.0.2.100, with username admin
(prompting the user to input a password at runtime), creating a VM
based on profile '1CPU-2.5GB' in foo.ova.
<BLANKLINE>
cot deploy foo.ova esxi 192.0.2.100 -u admin -c 1CPU-2.5GB
:param list example_list: List of (description, CLI example)
Expand Down
29 changes: 29 additions & 0 deletions COT/tests/test_doctests.py
@@ -0,0 +1,29 @@
#!/usr/bin/env python
#
# test_doctests.py - test runner for COT doctests
#
# July 2016, Glenn F. Matthews
# Copyright (c) 2016 the COT project developers.
# See the COPYRIGHT.txt file at the top-level directory of this distribution
# and at https://github.com/glennmatthews/cot/blob/master/COPYRIGHT.txt.
#
# This file is part of the Common OVF Tool (COT) project.
# It is subject to the license terms in the LICENSE.txt file found in the
# top-level directory of this distribution and at
# https://github.com/glennmatthews/cot/blob/master/LICENSE.txt. No part
# of COT, including this file, may be copied, modified, propagated, or
# distributed except according to the terms contained in the LICENSE.txt file.

"""Test runner for COT doctest tests."""

from doctest import DocTestSuite
from unittest import TestSuite


def load_tests(*_):
"""Load doctests as unittest test suite."""
suite = TestSuite()
suite.addTests(DocTestSuite('COT.cli'))
suite.addTests(DocTestSuite('COT.edit_hardware'))
suite.addTests(DocTestSuite('COT.ovf.ovf'))
return suite

0 comments on commit 26c8587

Please sign in to comment.