Skip to content

Commit

Permalink
refactor: move test cases of .inputs.inspect_input (doctest) to .test…
Browse files Browse the repository at this point in the history
…s.inputs
  • Loading branch information
ssato committed May 20, 2018
1 parent 6bb9528 commit 44d7dfe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
15 changes: 0 additions & 15 deletions anyconfig/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,6 @@ def inspect_input(input_):
:return: A tuple of (input_type, input_path, input_opener)
:raises: UnknownFileTypeError
>>> import os.path
>>> ipath_0 = os.path.join(os.path.dirname(__file__), "..",
... "tests/00-cnf.json")
>>> ipath_1 = anyconfig.utils.normpath(ipath_0)
>>> assert inspect_input(ipath_0) == (PATH_STR, ipath_1, open)
>>> assert inspect_input(open(ipath_0)) == (STREAM, ipath_1,
... anyconfig.utils.noop)
>>> from anyconfig.compat import pathlib
>>> if pathlib is not None:
... ipo = pathlib.Path(ipath_0)
... x = inspect_input(ipo)
... assert x == (PATH_OBJ, ipath_1, ipo.open)
"""
itype = guess_input_type(input_)

Expand Down
20 changes: 20 additions & 0 deletions tests/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@
IPATH_0_FULL = anyconfig.utils.normpath(IPATH_0)


class Test_30_inspect_input(unittest.TestCase):

def test_10_path_str(self):
self.assertEqual(TT.inspect_input(IPATH_0),
(TT.PATH_STR, IPATH_0_FULL, open))

def test_20_stream(self):
self.assertEqual(TT.inspect_input(open(IPATH_0)),
(TT.STREAM, IPATH_0_FULL,
anyconfig.utils.noop))

def test_30_path_obj(self):
if anyconfig.compat.pathlib is None:
return

ipo = anyconfig.compat.pathlib.Path(IPATH_0)
self.assertEqual(TT.inspect_input(ipo),
(TT.PATH_OBJ, IPATH_0_FULL, ipo.open))


class Test_50_find_parser(unittest.TestCase):
cpss = (CPS_BY_EXT, CPS_BY_TYPE)
(ipath, ipath_full) = (IPATH_0, IPATH_0_FULL)
Expand Down

0 comments on commit 44d7dfe

Please sign in to comment.