Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_local_1():
with example_work_directory('local_1'):
assert(Path('Cartfile.resolved').exists() == False)
output = runner.check_run('punic resolve')
assert(Path('Cartfile.resolved').open().read() == 'local "A" "."\n')
# TODO: This should NOT be created by a resolve.
# assert(Path('Carthage/Checkouts').exists() == False)
output = runner.check_run('punic fetch')
assert(Path('Carthage/Checkouts').is_dir() == True)
# TODO: This should NOT be created by a fetch.
# assert(Path('Carthage/Build').exists() == False)
output = runner.check_run('punic build')
assert(Path('Carthage/Build/Mac/A.framework').exists() == True)
assert(Path('Carthage/Build/Mac/A.dSYM').exists() == True)
def test_man_page_path_only_shipped():
assert man_pages.man_page_path("if64") == Path(cmk_path()) / "checkman" / "if64"
assert man_pages.man_page_path("not_existant") is None
def get_temp_dir(self):
testcase_name = calculate_testcase_name(self.testcase_context)
testcase_subdir = "{}_{}".format(self.__get_current_date(), testcase_name)
temp_dir = Path("/tmp", testcase_subdir)
temp_dir.mkdir()
self.__registered_dirs.append(temp_dir)
return temp_dir
"""Attachment with home directory tilde notation file path."""
template_path = Path(tmpdir/"template.txt")
template_path.write_text(textwrap.dedent(u"""\
TO: to@test.com
FROM: from@test.com
ATTACHMENT: ~/attachment.txt
Hello world
"""))
# Render will throw an error because we didn't create a file in the
# user's home directory. We'll just check the filename.
template_message = TemplateMessage(template_path)
with pytest.raises(MailmergeError) as err:
template_message.render({})
correct_path = Path.home() / "attachment.txt"
assert str(correct_path) in str(err)
self.assertIs(True, P('NUL').is_reserved())
self.assertIs(True, P('NUL.txt').is_reserved())
self.assertIs(True, P('com1').is_reserved())
self.assertIs(True, P('com9.bar').is_reserved())
self.assertIs(False, P('bar.com9').is_reserved())
self.assertIs(True, P('lpt1').is_reserved())
self.assertIs(True, P('lpt9.bar').is_reserved())
self.assertIs(False, P('bar.lpt9').is_reserved())
# Only the last component matters
self.assertIs(False, P('c:/NUL/con/baz').is_reserved())
# UNC paths are never reserved
self.assertIs(False, P('//my/share/nul/con/aux').is_reserved())
class PurePathTest(_BasePurePathTest, unittest.TestCase):
cls = pathlib.PurePath
def test_concrete_class(self):
p = self.cls('a')
self.assertIs(
type(p),
pathlib.PureWindowsPath
if os.name == 'nt' else pathlib.PurePosixPath)
def test_different_flavours_unequal(self):
p = pathlib.PurePosixPath('a')
q = pathlib.PureWindowsPath('a')
self.assertNotEqual(p, q)
@unittest.skipIf(sys.version_info < (3, 0),
'Most types are orderable in Python 2')
def test_different_flavours_unordered(self):
self.assertEqual(pp, P('/c'))
def test_div(self):
# Basically the same as joinpath()
P = self.cls
p = P('//a')
pp = p / 'b'
self.assertEqual(pp, P('//a/b'))
pp = P('/a') / '//c'
self.assertEqual(pp, P('//c'))
pp = P('//a') / '/c'
self.assertEqual(pp, P('/c'))
class PureWindowsPathTest(_BasePurePathTest, unittest.TestCase):
cls = pathlib.PureWindowsPath
equivalences = _BasePurePathTest.equivalences.copy()
equivalences.update({
'c:a': [('c:', 'a'), ('c:', 'a/'), ('/', 'c:', 'a')],
'c:/a': [
('c:/', 'a'), ('c:', '/', 'a'), ('c:', '/a'),
('/z', 'c:/', 'a'), ('//x/y', 'c:/', 'a'),
],
'//a/b/': [('//a/b',)],
'//a/b/c': [
('//a/b', 'c'), ('//a/b/', 'c'),
],
})
def test_str(self):
p = self.cls('a/b/c')
def test_different_flavours_unordered(self):
p = pathlib.PurePosixPath('a')
q = pathlib.PureWindowsPath('a')
with self.assertRaises(TypeError):
p < q
with self.assertRaises(TypeError):
p <= q
with self.assertRaises(TypeError):
p > q
with self.assertRaises(TypeError):
p >= q
def test_concrete_class(self):
p = self.cls('a')
self.assertIs(
type(p),
pathlib.PureWindowsPath
if os.name == 'nt' else pathlib.PurePosixPath)
def test_different_flavours_unequal(self):
p = pathlib.PurePosixPath('a')
q = pathlib.PureWindowsPath('a')
self.assertNotEqual(p, q)