def test_path_values_with_check(self): value = PathValue() with env(DJANGO_TEST='/'): self.assertEqual(value.setup('TEST'), '/') with env(DJANGO_TEST='~/'): self.assertEqual(value.setup('TEST'), os.path.expanduser('~')) with env(DJANGO_TEST='/does/not/exist'): self.assertRaises(ValueError, value.setup, 'TEST')
def test_path_values_no_check(self): value = PathValue(check_exists=False) with env(DJANGO_TEST="/"): self.assertEqual(value.setup("TEST"), "/") with env(DJANGO_TEST="~/spam/eggs"): self.assertEqual(value.setup("TEST"), os.path.join(os.path.expanduser("~"), "spam", "eggs")) with env(DJANGO_TEST="/does/not/exist"): self.assertEqual(value.setup("TEST"), "/does/not/exist")
def test_path_values_with_check(self): value = PathValue() with env(DJANGO_TEST="/"): self.assertEqual(value.setup("TEST"), "/") with env(DJANGO_TEST="~/"): self.assertEqual(value.setup("TEST"), os.path.expanduser("~")) with env(DJANGO_TEST="/does/not/exist"): self.assertRaises(ValueError, value.setup, "TEST")
def test_path_values_no_check(self): value = PathValue(check_exists=False) with env(DJANGO_TEST='/'): self.assertEqual(value.setup('TEST'), '/') with env(DJANGO_TEST='~/spam/eggs'): self.assertEqual(value.setup('TEST'), os.path.join(os.path.expanduser('~'), 'spam', 'eggs')) with env(DJANGO_TEST='/does/not/exist'): self.assertEqual(value.setup('TEST'), '/does/not/exist')
def test_path_values_no_check(self): value = PathValue(check_exists=False) with env(DJANGO_TEST='/'): self.assertEqual(value.setup('TEST'), '/') with env(DJANGO_TEST='~/spam/eggs'): self.assertEqual( value.setup('TEST'), os.path.join(os.path.expanduser('~'), 'spam', 'eggs')) with env(DJANGO_TEST='/does/not/exist'): self.assertEqual(value.setup('TEST'), '/does/not/exist')