def test_release_mode_failure_with_lingua_no_modify(self): with tempfile.TemporaryDirectory() as d: open(os.path.join(d, "test.po"), "w").close() with open(os.path.join(d, "LINGUAS"), "w") as linguas: linguas.write("test other\n") # Check that test.po is removed and test is *not* removed from LINGUAS self.assertTrue(testFile(os.path.join(d, "test.po"), releaseMode=True, modifyLinguas=False)) self.assertFalse(os.path.exists(os.path.join(d, "test.po"))) with open(os.path.join(d, "LINGUAS"), "r") as linguas: self.assertEqual(linguas.read().strip(), "test other")
def test_release_mode_failure(self): p = tempfile.NamedTemporaryFile(suffix='.po', delete=False) try: # testFile should return True but delete the file self.assertTrue(testFile(p.name, releaseMode=True)) self.assertFalse(os.path.exists(p.name)) finally: try: p.close() os.unlink(p.name) except FileNotFoundError: pass
def test_release_mode_failure_with_lingua(self): with tempfile.TemporaryDirectory() as d: open(os.path.join(d, "test.po"), "w").close() with open(os.path.join(d, "LINGUAS"), "w") as linguas: linguas.write("test other\n") # Check that test.po is removed and test is removed from LINGUAS self.assertTrue( testFile(os.path.join(d, "test.po"), releaseMode=True)) self.assertFalse(os.path.exists(os.path.join(d, "test.po"))) with open(os.path.join(d, "LINGUAS"), "r") as linguas: self.assertEqual(linguas.read().strip(), "other")
def test_release_mode_success(self): with pofile_from_entry() as p: self.assertTrue(testFile(p.name, releaseMode=True)) self.assertTrue(os.path.exists(p.name))
def test_failure(self): with pofile_from_entry() as p: self.assertFalse(testFile(p.name))
def test_success(self): with pofile_from_entry() as p: self.assertTrue(testFile(p.name))