Ticket #16964: tests.diff

File tests.diff, 1.4 KB (added by Jonas H., 13 years ago)

Tests that demonstrate the bug

  • tests/modeltests/files/tests.py

    diff --git a/tests/modeltests/files/tests.py b/tests/modeltests/files/tests.py
    index e8e7a76..82a1c7d 100644
    a b class FileTests(TestCase):  
    5454        self.assertEqual(list(obj1.normal.chunks(chunk_size=2)), ["co", "nt", "en", "t"])
    5555        obj1.normal.close()
    5656
     57        # Files can be edited.
     58        obj1 = Storage.objects.get()
     59        obj1.normal.open('w')
     60        obj1.normal.write('new content')
     61        obj1.normal.close()
     62        obj1.normal.open()
     63        self.assertEqual(obj1.normal.read(), 'new content')
     64
    5765        # Save another file with the same name.
    5866        obj2 = Storage()
    5967        obj2.normal.save("django_test.txt", ContentFile("more content"))
  • tests/regressiontests/file_storage/tests.py

    diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py
    index 6a7a46a..6f9af1f 100644
    a b class FileStorageTests(unittest.TestCase):  
    116116
    117117        f = self.storage.open('storage_test', 'r')
    118118        self.assertEqual(f.read(), 'storage contents')
    119         f.close()
     119        f.open('w')
     120        f.write('new contents')
     121        f.open('r')
     122        self.assertEqual(f.read(), 'new contents')
    120123
    121124        self.storage.delete('storage_test')
    122125        self.assertFalse(self.storage.exists('storage_test'))
Back to Top