Example #1
0
class TestScoresheetFile:
    def setup(self):
        self.sheet = Scoresheet()
        self.sheet[(u"a", u"b")] = 2.0
        self.sheet[(u"b", u"\xe9")] = 1.0
        self.expected = b"b\ta\t2.0\n\xc3\xa9\tb\t1.0\n"

    def test_to_file(self):
        with temp_file() as fname:
            self.sheet.to_file(fname)

            with open(fname, "rb") as fh:
                assert fh.read() == self.expected

    def test_from_file(self):
        with temp_file() as fname:
            with open(fname, "wb") as fh:
                fh.write(self.expected)

            sheet = Scoresheet.from_file(fname)
            assert sheet == self.sheet
Example #2
0
class TestScoresheetFile:
    def setup(self):
        self.sheet = Scoresheet()
        self.sheet[(u'a', u'b')] = 2.0
        self.sheet[(u'b', u'\xe9')] = 1.0
        self.expected = b"b\ta\t2.0\n\xc3\xa9\tb\t1.0\n"

    def test_to_file(self):
        with temp_file() as fname:
            self.sheet.to_file(fname)

            with open(fname, "rb") as fh:
                assert_equal(fh.read(), self.expected)

    def test_from_file(self):
        with temp_file() as fname:
            with open(fname, "wb") as fh:
                fh.write(self.expected)

            sheet = Scoresheet.from_file(fname)
            assert_dict_equal(sheet, self.sheet)
Example #3
0
class TestScoresheetFile:
    def setup(self):
        self.sheet = Scoresheet()
        self.sheet[(u'a', u'b')] = 2.0
        self.sheet[(u'b', u'\xe9')] = 1.0
        self.expected = b"b\ta\t2.0\n\xc3\xa9\tb\t1.0\n"

    def test_to_file(self):
        with temp_file() as fname:
            self.sheet.to_file(fname)

            with open(fname, "rb") as fh:
                assert_equal(fh.read(), self.expected)

    def test_from_file(self):
        with temp_file() as fname:
            with open(fname, "wb") as fh:
                fh.write(self.expected)

            sheet = Scoresheet.from_file(fname)
            assert_dict_equal(sheet, self.sheet)