Assure bindep can be called as a module
- assure we can all bindep as a module (python -m bindep) - add test the assures output is the same regardless how is called - include argparse fix which needs to know executable name when called as modules. - enables use of bindep without needing to have it in PATH Change-Id: Ib2aac359e2f23cb0ac7857835905e0a02e90888d
This commit is contained in:
parent
a1f30f40ab
commit
6deb027936
|
@ -27,7 +27,7 @@ logging.basicConfig(
|
|||
|
||||
|
||||
def main(depends=None):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser = argparse.ArgumentParser(prog="bindep")
|
||||
parser.add_argument(
|
||||
"--brief", "-b", action="store_true", dest="brief",
|
||||
help="List only missing packages one per line.")
|
|
@ -16,6 +16,8 @@
|
|||
# limitations under the License.
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from textwrap import dedent
|
||||
|
||||
from fixtures import FakeLogger
|
||||
|
@ -25,7 +27,7 @@ from fixtures import TempDir
|
|||
import mock
|
||||
from testtools import TestCase
|
||||
|
||||
from bindep.main import main
|
||||
from bindep.__main__ import main
|
||||
|
||||
|
||||
class MainFixture(Fixture):
|
||||
|
@ -196,3 +198,11 @@ class TestMain(TestCase):
|
|||
depends.platform_profiles.assert_called_once_with()
|
||||
depends.active_rules.assert_called_once_with(["default"])
|
||||
depends.check_rules.assert_called_once_with([])
|
||||
|
||||
def test_called_as_module(self):
|
||||
"""Assures calling as module reports the same version."""
|
||||
result = subprocess.check_output(
|
||||
["bindep", "--version"])
|
||||
result2 = subprocess.check_output(
|
||||
[sys.executable, "-m", "bindep", "--version"])
|
||||
assert result == result2
|
||||
|
|
|
@ -16,7 +16,7 @@ here is a basic outline of the source implementation:
|
|||
.. automodule:: bindep.depends
|
||||
:members:
|
||||
|
||||
.. automodule:: bindep.main
|
||||
.. automodule:: bindep.__main__
|
||||
:members:
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue