def test_scoresheet(): sheet = Scoresheet() t = ('a', 'b') sheet[t] = 5 assert_equal(len(sheet), 1) assert_equal(sheet.items(), [(Pair('a', 'b'), 5.0)]) assert_equal(sheet[t], 5.0) del sheet[t] assert_equal(len(sheet), 0)
def test_scoresheet(): sheet = Scoresheet() t = ('a', 'b') sheet[t] = 5 assert_equal(len(sheet), 1) assert_equal(list(sheet.items()), [(Pair('a', 'b'), 5.0)]) assert_equal(sheet[t], 5.0) del sheet[t] assert_equal(len(sheet), 0)
def test_scoresheet(): sheet = Scoresheet() t = ("a", "b") sheet[t] = 5 assert len(sheet) == 1 assert list(sheet.items()) == [(Pair("a", "b"), 5.0)] assert sheet[t] == 5.0 del sheet[t] assert len(sheet) == 0
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)
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
def test_scoresheet_process_data(): t = ('a', 'b') d = {t: 5} G = nx.Graph() G.add_edge(*t, weight=5) s = [(t, 5)] for x in (d, G, s): sheet = Scoresheet(x) assert_equal(sheet[t], 5.0)
def test_scoresheet_process_data(): t = ("a", "b") d = {t: 5} G = nx.Graph() G.add_edge(*t, weight=5) s = [(t, 5)] for x in (d, G, s): sheet = Scoresheet(x) assert sheet[t] == 5.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)
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
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 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"