Changeset - 2d92227f576d
[Not reviewed]
default
0 1 0
domruf - 10 years ago 2016-03-02 19:50:51
dominikruf@gmail.com
tests: binary streams/files need to be opened in binary mode

Without binary, the stream may be closed on EOF character
http://stackoverflow.com/a/9069009/7029 .
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/vcs/test_archives.py
Show inline comments
 
@@ -65,30 +65,30 @@ class ArchivesTestCaseMixin(_BackendTest
 

	
 
        outfile = tarfile.open(path, 'r|bz2')
 
        outfile.extractall(outdir)
 

	
 
        for x in xrange(5):
 
            node_path = '%d/file_%d.txt' % (x, x)
 
            self.assertEqual(
 
                open(os.path.join(outdir, 'repo/' + node_path)).read(),
 
                self.tip.get_node(node_path).content)
 

	
 
    def test_archive_default_stream(self):
 
        tmppath = tempfile.mkstemp()[1]
 
        with open(tmppath, 'w') as stream:
 
        with open(tmppath, 'wb') as stream:
 
            self.tip.fill_archive(stream=stream)
 
        mystream = StringIO.StringIO()
 
        self.tip.fill_archive(stream=mystream)
 
        mystream.seek(0)
 
        with open(tmppath, 'r') as f:
 
        with open(tmppath, 'rb') as f:
 
            self.assertEqual(f.read(), mystream.read())
 

	
 
    def test_archive_wrong_kind(self):
 
        with self.assertRaises(VCSError):
 
            self.tip.fill_archive(kind='wrong kind')
 

	
 
    def test_archive_empty_prefix(self):
 
        with self.assertRaises(VCSError):
 
            self.tip.fill_archive(prefix='')
 

	
 
    def test_archive_prefix_with_leading_slash(self):
 
        with self.assertRaises(VCSError):
0 comments (0 inline, 0 general)