diff options
Diffstat (limited to 'tests/propertiestests.py')
-rw-r--r-- | tests/propertiestests.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/propertiestests.py b/tests/propertiestests.py index 46346c4..e1f6f4b 100644 --- a/tests/propertiestests.py +++ b/tests/propertiestests.py @@ -15,6 +15,8 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import unittest +import uuid +import os from sugar.tutorius.constraints import * from sugar.tutorius.properties import * @@ -378,18 +380,31 @@ class TEnumPropertyTest(unittest.TestCase): class TFilePropertyTest(unittest.TestCase): def setUp(self): + # Create some sample, unique files for the tests + self.temp_filename1 = "sample_file1_" + str(uuid.uuid1()) + ".txt" + self.temp_file1 = file(self.temp_filename1, "w") + self.temp_file1.close() + self.temp_filename2 = "sample_file2_" + str(uuid.uuid1()) + ".txt" + self.temp_file2 = file(self.temp_filename2, "w") + self.temp_file2.close() + class klass(TPropContainer): - prop = TFileProperty("propertiestests.py") + prop = TFileProperty(self.temp_filename1) self.obj = klass() + + def tearDown(self): + # Unlink the files from the disk when tests are over + os.unlink(self.temp_filename1) + os.unlink(self.temp_filename2) def test_basic_file(self): - assert self.obj.prop == "propertiestests.py", "Could not set initial value" + assert self.obj.prop == self.temp_filename1, "Could not set initial value" assert type(self.obj).prop.type == "file", "Wrong type for TFileProperty : %s"%type(self.obj).prop.type - self.obj.prop = "run-tests.py" + self.obj.prop = self.temp_filename2 - assert self.obj.prop == "run-tests.py", "Could not change value" + assert self.obj.prop == self.temp_filename2, "Could not change value" try: self.obj.prop = "unknown/file/on/disk.gif" |