Exemplo n.º 1
0
 def test_temp_dir(self):
     with temp_dir() as d:
         self.assertTrue(osp.isdir(d))
     self.assertFalse(osp.isdir(d))
     with temp_dir(cleanup=False) as d:
         self.assertTrue(osp.isdir(d))
     self.assertTrue(osp.isdir(d))
Exemplo n.º 2
0
 def test_file_download(self):
     url = 'http://ovh.net/files/md5sum.txt'
     session = requests.Session()
     with temp_dir() as d:
         file_path, content_type = download_http_url(
             url,
             session,
             d,
             filename='foo.txt')
         self.assertIsNotNone(file_path)
         self.assertEqual(osp.abspath(file_path), file_path)
         self.assertIsNotNone(content_type)
         self.assertEquals(content_type, 'text/plain')
         self.assertTrue(osp.isfile(file_path))