From cf40c1951f4f0f26090226fb4969ca147341a031 Mon Sep 17 00:00:00 2001 From: mike Date: Fri, 02 Oct 2009 22:24:56 +0000 Subject: LP 439980 : Refactored the XMLSerializer to support complex components; Corrected specs for the addons properties and constructor parameters names; Moved all existing actions and events to components (except a few left in code for testing purposes) --- (limited to 'tests/propertiestests.py') 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" -- cgit v0.9.1