Exemple #1
0
 def test_equality(self):
     for spec_list_text in self.examples:
         with self.subTest(spec=spec_list_text):
             slist1 = base.Spec(spec_list_text)
             slist2 = base.Spec(spec_list_text)
             self.assertEqual(slist1, slist2)
             self.assertFalse(slist1 == spec_list_text)
    def test_parsing_split(self):
        for spec_list_texts, specs in self.split_examples.items():
            spec_list = base.Spec(*spec_list_texts)

            self.assertEqual(','.join(spec_list_texts), str(spec_list))
            self.assertEqual(specs, [str(spec) for spec in spec_list])
            self.assertEqual(spec_list, base.Spec(','.join(spec_list_texts)))

            for spec_text in specs:
                self.assertTrue(repr(base.SpecItem(spec_text)) in repr(spec_list))
    def test_parsing_split(self):
        for spec_list_texts, specs in self.split_examples.items():
            with self.subTest(spec=spec_list_texts):
                spec_list = base.Spec(*spec_list_texts)

                self.assertEqual(','.join(spec_list_texts), str(spec_list))
                self.assertCountEqual(specs, [str(spec) for spec in spec_list])
                self.assertEqual(spec_list, base.Spec(','.join(spec_list_texts)))

                for spec_text in specs:
                    self.assertIn(str(base.SpecItem(spec_text)), repr(spec_list))
 def test_select_incompatible(self):
     s = base.Spec('>=0.1.1,!=0.1.4')
     res = s.select([
         base.Version('0.1.0'),
         base.Version('0.1.4'),
         base.Version('0.1.4-alpha'),
     ])
     self.assertIsNone(res)
Exemple #5
0
    def test_parsing(self):
        for spec_list_text, specs in self.examples.items():
            with self.subTest(spec=spec_list_text):
                spec_list = base.Spec(spec_list_text)

                self.assertEqual(spec_list_text, str(spec_list))
                self.assertNotEqual(spec_list_text, spec_list)
                self.assertCountEqual(specs, [str(spec) for spec in spec_list])
 def test_filter_incompatible(self):
     s = base.Spec('>=0.1.1,!=0.1.4')
     res = tuple(s.filter([
         base.Version('0.1.0'),
         base.Version('0.1.4'),
         base.Version('0.1.4-alpha'),
     ]))
     self.assertEqual((), res)
    def test_parsing(self):
        for spec_list_text, specs in self.examples.items():
            spec_list = base.Spec(spec_list_text)

            self.assertEqual(spec_list_text, str(spec_list))
            self.assertNotEqual(spec_list_text, spec_list)
            self.assertEqual(specs, [str(spec) for spec in spec_list])

            for spec_text in specs:
                self.assertTrue(repr(base.SpecItem(spec_text)) in repr(spec_list))
    def test_select_compatible(self):
        s = base.Spec('>=0.1.1,!=0.1.4,<0.2.0')
        res = s.select([
            base.Version('0.1.0'),
            base.Version('0.1.1'),
            base.Version('0.1.5'),
            base.Version('0.1.4-alpha'),
            base.Version('0.1.2'),
            base.Version('0.2.0-rc1'),
            base.Version('3.14.15'),
        ])

        self.assertEqual(base.Version('0.1.5'), res)
    def test_matches(self):
        for spec_list_text, versions in self.matches.items():
            spec_list = base.Spec(spec_list_text)
            matching, failing = versions

            for version_text in matching:
                version = base.Version(version_text)
                self.assertTrue(version in spec_list,
                    "%r should be in %r" % (version, spec_list))
                self.assertTrue(spec_list.match(version),
                    "%r should match %r" % (version, spec_list))

            for version_text in failing:
                version = base.Version(version_text)
                self.assertFalse(version in spec_list,
                    "%r should not be in %r" % (version, spec_list))
                self.assertFalse(spec_list.match(version),
                    "%r should not match %r" % (version, spec_list))
    def test_filter_compatible(self):
        s = base.Spec('>=0.1.1,!=0.1.4,<0.2.0')
        res = tuple(s.filter([
            base.Version('0.1.0'),
            base.Version('0.1.1'),
            base.Version('0.1.5'),
            base.Version('0.1.4-alpha'),
            base.Version('0.1.2'),
            base.Version('0.2.0-rc1'),
            base.Version('3.14.15'),
        ]))

        expected = (
            base.Version('0.1.1'),
            base.Version('0.1.5'),
            base.Version('0.1.2'),
        )

        self.assertEqual(expected, res)
 def test_hash(self):
     self.assertEqual(
         1, len(set([base.Spec('>=0.1.1'),
                     base.Spec('>=0.1.1')])))
 def test_contains(self):
     self.assertFalse('ii' in base.Spec('>=0.1.1'))
 def test_select_empty(self):
     s = base.Spec('>=0.1.1')
     self.assertIsNone(s.select(()))
 def test_filter_empty(self):
     s = base.Spec('>=0.1.1')
     res = tuple(s.filter(()))
     self.assertEqual((), res)