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
 
@@ -71,18 +71,18 @@ class ArchivesTestCaseMixin(_BackendTest
 
            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')
 

	
0 comments (0 inline, 0 general)