kopia lustrzana https://github.com/collective/icalendar
				
				
				
			Merge pull request #213 from jdufresne/resource-warnings
Fix all "ResourceWarning: unclosed file ..." warnings during testspull/211/head
						commit
						b198f54e8e
					
				|  | @ -14,7 +14,8 @@ class TestEncoding(unittest.TestCase): | ||||||
|         """ |         """ | ||||||
|         try: |         try: | ||||||
|             directory = os.path.dirname(__file__) |             directory = os.path.dirname(__file__) | ||||||
|             data = open(os.path.join(directory, 'x_location.ics'), 'rb').read() |             with open(os.path.join(directory, 'x_location.ics'), 'rb') as fp: | ||||||
|  |                 data = fp.read() | ||||||
|             cal = icalendar.Calendar.from_ical(data) |             cal = icalendar.Calendar.from_ical(data) | ||||||
|             for event in cal.walk('vevent'): |             for event in cal.walk('vevent'): | ||||||
|                 self.assertEqual(len(event.errors), 1, 'Got too many errors') |                 self.assertEqual(len(event.errors), 1, 'Got too many errors') | ||||||
|  |  | ||||||
|  | @ -11,7 +11,8 @@ class TestEncoding(unittest.TestCase): | ||||||
| 
 | 
 | ||||||
|     def test_create_from_ical(self): |     def test_create_from_ical(self): | ||||||
|         directory = os.path.dirname(__file__) |         directory = os.path.dirname(__file__) | ||||||
|         data = open(os.path.join(directory, 'encoding.ics'), 'rb').read() |         with open(os.path.join(directory, 'encoding.ics'), 'rb') as fp: | ||||||
|  |             data = fp.read() | ||||||
|         cal = icalendar.Calendar.from_ical(data) |         cal = icalendar.Calendar.from_ical(data) | ||||||
| 
 | 
 | ||||||
|         self.assertEqual(cal['prodid'].to_ical().decode('utf-8'), |         self.assertEqual(cal['prodid'].to_ical().decode('utf-8'), | ||||||
|  |  | ||||||
|  | @ -12,10 +12,9 @@ class TestMultiple(unittest.TestCase): | ||||||
|     def test_multiple(self): |     def test_multiple(self): | ||||||
| 
 | 
 | ||||||
|         directory = os.path.dirname(__file__) |         directory = os.path.dirname(__file__) | ||||||
|         cals = Calendar.from_ical( |         with open(os.path.join(directory, 'multiple.ics'), 'rb') as fp: | ||||||
|             open(os.path.join(directory, 'multiple.ics'), 'rb').read(), |             data = fp.read() | ||||||
|             multiple=True |         cals = Calendar.from_ical(data, multiple=True) | ||||||
|         ) |  | ||||||
| 
 | 
 | ||||||
|         self.assertEqual(len(cals), 2) |         self.assertEqual(len(cals), 2) | ||||||
|         self.assertSequenceEqual([comp.name for comp in cals[0].walk()], |         self.assertSequenceEqual([comp.name for comp in cals[0].walk()], | ||||||
|  |  | ||||||
|  | @ -12,9 +12,9 @@ class TestRecurrence(unittest.TestCase): | ||||||
| 
 | 
 | ||||||
|     def setUp(self): |     def setUp(self): | ||||||
|         directory = os.path.dirname(__file__) |         directory = os.path.dirname(__file__) | ||||||
|         self.cal = icalendar.Calendar.from_ical( |         with open(os.path.join(directory, 'recurrence.ics'), 'rb') as fp: | ||||||
|             open(os.path.join(directory, 'recurrence.ics'), 'rb').read() |             data = fp.read() | ||||||
|         ) |         self.cal = icalendar.Calendar.from_ical(data) | ||||||
| 
 | 
 | ||||||
|     def test_recurrence_exdates_one_line(self): |     def test_recurrence_exdates_one_line(self): | ||||||
|         first_event = self.cal.walk('vevent')[0] |         first_event = self.cal.walk('vevent')[0] | ||||||
|  |  | ||||||
|  | @ -12,9 +12,9 @@ class TestTimezoned(unittest.TestCase): | ||||||
| 
 | 
 | ||||||
|     def test_create_from_ical(self): |     def test_create_from_ical(self): | ||||||
|         directory = os.path.dirname(__file__) |         directory = os.path.dirname(__file__) | ||||||
|         cal = icalendar.Calendar.from_ical( |         with open(os.path.join(directory, 'timezoned.ics'), 'rb') as fp: | ||||||
|             open(os.path.join(directory, 'timezoned.ics'), 'rb').read() |             data = fp.read() | ||||||
|         ) |         cal = icalendar.Calendar.from_ical(data) | ||||||
| 
 | 
 | ||||||
|         self.assertEqual( |         self.assertEqual( | ||||||
|             cal['prodid'].to_ical(), |             cal['prodid'].to_ical(), | ||||||
|  | @ -151,9 +151,9 @@ class TestTimezoneCreation(unittest.TestCase): | ||||||
|         RFC""" |         RFC""" | ||||||
| 
 | 
 | ||||||
|         directory = os.path.dirname(__file__) |         directory = os.path.dirname(__file__) | ||||||
|         cal = icalendar.Calendar.from_ical( |         with open(os.path.join(directory, 'america_new_york.ics'), 'rb') as fp: | ||||||
|             open(os.path.join(directory, 'america_new_york.ics'), 'rb').read() |             data = fp.read() | ||||||
|         ) |         cal = icalendar.Calendar.from_ical(data) | ||||||
| 
 | 
 | ||||||
|         tz = cal.walk('VEVENT')[0]['DTSTART'][0].dt.tzinfo |         tz = cal.walk('VEVENT')[0]['DTSTART'][0].dt.tzinfo | ||||||
|         self.assertEqual(str(tz), 'custom_America/New_York') |         self.assertEqual(str(tz), 'custom_America/New_York') | ||||||
|  | @ -188,9 +188,9 @@ class TestTimezoneCreation(unittest.TestCase): | ||||||
|         self.maxDiff = None |         self.maxDiff = None | ||||||
| 
 | 
 | ||||||
|         directory = os.path.dirname(__file__) |         directory = os.path.dirname(__file__) | ||||||
|         cal = icalendar.Calendar.from_ical( |         with open(os.path.join(directory, 'pacific_fiji.ics'), 'rb') as fp: | ||||||
|             open(os.path.join(directory, 'pacific_fiji.ics'), 'rb').read() |             data = fp.read() | ||||||
|         ) |         cal = icalendar.Calendar.from_ical(data) | ||||||
| 
 | 
 | ||||||
|         tz = cal.walk('VEVENT')[0]['DTSTART'][0].dt.tzinfo |         tz = cal.walk('VEVENT')[0]['DTSTART'][0].dt.tzinfo | ||||||
|         self.assertEqual(str(tz), 'custom_Pacific/Fiji') |         self.assertEqual(str(tz), 'custom_Pacific/Fiji') | ||||||
|  |  | ||||||
|  | @ -393,7 +393,8 @@ class TestCal(unittest.TestCase): | ||||||
|         import tempfile |         import tempfile | ||||||
|         import os |         import os | ||||||
|         directory = tempfile.mkdtemp() |         directory = tempfile.mkdtemp() | ||||||
|         open(os.path.join(directory, 'test.ics'), 'wb').write(cal.to_ical()) |         with open(os.path.join(directory, 'test.ics'), 'wb') as fp: | ||||||
|  |             fp.write(cal.to_ical()) | ||||||
| 
 | 
 | ||||||
|         # Parsing a complete calendar from a string will silently ignore wrong |         # Parsing a complete calendar from a string will silently ignore wrong | ||||||
|         # events but adding the error information to the component's 'errors' |         # events but adding the error information to the component's 'errors' | ||||||
|  |  | ||||||
		Ładowanie…
	
		Reference in New Issue
	
	 Markus Unterwaditzer
						Markus Unterwaditzer