def test_yml_or_yaml_path(self): temp_dir = tempfile.gettempdir() fd, temp_path = tempfile.mkstemp(suffix='.yml') os.close(fd) rootname = os.path.splitext(os.path.basename(temp_path))[0] self.assertEqual(temp_path, yml_or_yaml_path(temp_dir, rootname)) os.remove(temp_path) fd, temp_path = tempfile.mkstemp(suffix='.yaml') os.close(fd) rootname = os.path.splitext(os.path.basename(temp_path))[0] self.assertEqual(temp_path, yml_or_yaml_path(temp_dir, rootname)) os.remove(temp_path)
def test_yml_or_yaml_both(self): temp_dir = tempfile.gettempdir() fd, yml_path = tempfile.mkstemp(suffix='.yml') os.close(fd) rootname = os.path.splitext(os.path.basename(yml_path))[0] yaml_path = os.path.join(temp_dir, rootname) + '.yaml' with open(yaml_path, 'w') as f: pass # Both cases raise exception with self.assertRaises(ValueError): yml_or_yaml_path(temp_dir, rootname) os.remove(yml_path) os.remove(yaml_path)
def test_yml_or_yaml_neither(self): the_dir = '/no/such/dir' self.assertEqual( os.path.join(the_dir, 'bogus') + '.yml', yml_or_yaml_path(the_dir, 'bogus'))
def test_yml_or_yaml_neither(self): the_dir = '/no/such/dir' self.assertEqual(os.path.join(the_dir, 'bogus') + '.yml', yml_or_yaml_path(the_dir, 'bogus'))