Merge "Check that the argument is in fact a directory"
This commit is contained in:
commit
5b3477502c
@ -263,6 +263,9 @@ def main(argv=None, stdout=None, _worker=None):
|
||||
if len(args) != 1:
|
||||
print("Must specify directory to update")
|
||||
raise Exception("Must specify one and only one directory to update.")
|
||||
if not os.path.isdir(args[0]):
|
||||
print("%s is not a directory." % (args[0]))
|
||||
raise Exception("%s is not a directory." % (args[0]))
|
||||
if stdout is None:
|
||||
stdout = sys.stdout
|
||||
if _worker is None:
|
||||
|
@ -19,6 +19,7 @@ import sys
|
||||
import textwrap
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
import testscenarios
|
||||
import testtools
|
||||
from testtools import matchers
|
||||
@ -216,7 +217,8 @@ Syncing setup.py
|
||||
|
||||
class TestMain(testtools.TestCase):
|
||||
|
||||
def test_smoke(self):
|
||||
@mock.patch('os.path.isdir', return_value=True)
|
||||
def test_smoke(self, mock_isdir):
|
||||
def check_params(
|
||||
root, source, suffix, softupdate, hacking, stdout, verbose,
|
||||
non_std_reqs):
|
||||
@ -232,14 +234,29 @@ class TestMain(testtools.TestCase):
|
||||
with fixtures.EnvironmentVariable('NON_STANDARD_REQS', '1'):
|
||||
update.main(
|
||||
['--source', '/dev/null', '/dev/zero'], _worker=check_params)
|
||||
self.expectThat(mock_isdir.called, matchers.Equals(True))
|
||||
|
||||
def test_suffix(self):
|
||||
@mock.patch('os.path.isdir', return_value=True)
|
||||
def test_suffix(self, mock_isdir):
|
||||
def check_params(
|
||||
root, source, suffix, softupdate, hacking, stdout, verbose,
|
||||
non_std_reqs):
|
||||
self.expectThat(suffix, matchers.Equals('global'))
|
||||
|
||||
update.main(['-o', 'global', '/dev/zero'], _worker=check_params)
|
||||
self.expectThat(mock_isdir.called, matchers.Equals(True))
|
||||
|
||||
def test_isdirectory(self):
|
||||
def never_called(
|
||||
root, source, suffix, softupdate, hacking, stdout, verbose,
|
||||
non_std_reqs):
|
||||
self.expectThat(False, matchers.Equals(True),
|
||||
message=("update.main() should riase an "
|
||||
"excpetion before getting here"))
|
||||
|
||||
with testtools.ExpectedException(Exception,
|
||||
"/dev/zero is not a directory"):
|
||||
update.main(['/dev/zero'], _worker=never_called)
|
||||
|
||||
|
||||
class TestSyncRequirementsFile(testtools.TestCase):
|
||||
|
@ -10,6 +10,7 @@ testscenarios>=0.4 # Apache-2.0/BSD
|
||||
testtools>=1.4.0 # MIT
|
||||
virtualenv # MIT
|
||||
setuptools>=16.0 # PSF/ZPL
|
||||
mock>=1.2 # BSD
|
||||
|
||||
# this is required for the docs build jobs
|
||||
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 # BSD
|
||||
|
Loading…
Reference in New Issue
Block a user