def make_candidates(self): C = namedtuple("C", "src, dst, expected") self.candidates = [ C(src=self.semver, dst=Semver(1, 4, 2), expected=True), C(src=self.semver, dst=Semver(2, 4, 2), expected=False), C(src=self.semver, dst=Semver(1, 8, 2), expected=False), C(src=self.semver, dst=Semver(1, 4, 4), expected=False), ]
def make_candidates(self): C = namedtuple("C", "greater, less, expected") self.candidates = [ C(greater=self.semver, less=Semver(0, 4, 2), expected=True), C(greater=self.semver, less=Semver(1, 2, 2), expected=True), C(greater=self.semver, less=Semver(1, 4, 0), expected=True), C(greater=self.semver, less=Semver(2, 4, 2), expected=False), C(greater=self.semver, less=Semver(1, 8, 2), expected=False), C(greater=self.semver, less=Semver(1, 4, 4), expected=False), ]
def test_整数型以外で初期化するとTypeErrorが返ってくること(self): with self.assertRaises(TypeError): Semver(major='1')
def test_プラスで初期化できること(self): self.assertEqual(1, Semver(major=1).major)
def setUp(self): self.semver = Semver(1, 4, 2)
def test_マイナスで初期化するとValueErrorが返ってくること(self): with self.assertRaises(ValueError): Semver(patch=-1)
def test_プラスで初期化できること(self): self.assertEqual(1, Semver(patch=1).patch)
def test_以上とより大きいが違うこと(self): self.assertTrue(self.semver >= Semver(1, 4, 2)) self.assertFalse(self.semver > Semver(1, 4, 2))