def test_from_namespaces(self):
     """Test construction from list of namespaces."""
     self.assertEqual(RegexSet.from_namespaces([]), RegexSet([], []))
     self.assertEqual(
         RegexSet.from_namespaces(["db.bar", "db_*.foo", "db2.*"]),
         RegexSet(
             [namespace_to_regex("db_*.foo"),
              namespace_to_regex("db2.*")], ["db.bar"]))
コード例 #2
0
 def test_from_namespaces(self):
     """Test construction from list of namespaces."""
     self.assertEqual(RegexSet.from_namespaces([]),
                      RegexSet([], []))
     self.assertEqual(RegexSet.from_namespaces(["db.bar", "db_*.foo",
                                                "db2.*"]),
                      RegexSet([namespace_to_regex("db_*.foo"),
                                namespace_to_regex("db2.*")],
                               ["db.bar"]))
コード例 #3
0
 def test_contains(self):
     """Test membership query."""
     regex_set = RegexSet.from_namespaces(["db.bar", "db_*.foo", "db2.*"])
     self.assertTrue("db.bar" in regex_set)
     self.assertTrue("db_1.foo" in regex_set)
     self.assertTrue("db2.bar" in regex_set)
     self.assertTrue("db2.bar2" in regex_set)
     self.assertFalse("not.found" in regex_set)
     self.assertFalse("db_not.found" in regex_set)
コード例 #4
0
 def test_discard(self):
     """Test discarding a string."""
     regex_set = RegexSet.from_namespaces(["db.bar"])
     self.assertTrue("db.bar" in regex_set)
     regex_set.discard("db.bar")
     self.assertFalse("db.bar" in regex_set)
コード例 #5
0
 def test_add(self):
     """Test adding a new string."""
     regex_set = RegexSet.from_namespaces([])
     self.assertFalse("string.found" in regex_set)
     regex_set.add("string.found")
     self.assertTrue("string.found" in regex_set)