class TestRstr(unittest.TestCase): def setUp(self) -> None: self.rs = Rstr() def test_specific_length(self) -> None: assert_matches('^A{5}$', self.rs.rstr('A', 5)) def test_length_range(self) -> None: assert_matches('^A{11,20}$', self.rs.rstr('A', 11, 20)) def test_custom_alphabet(self) -> None: assert_matches('^A{1,10}$', self.rs.rstr('AA')) def test_alphabet_as_list(self) -> None: assert_matches('^A{1,10}$', self.rs.rstr(['A', 'A'])) def test_include(self) -> None: assert_matches('^[ABC]*@[ABC]*$', self.rs.rstr('ABC', include='@')) def test_include_specific_length(self) -> None: ''' Verify including characters doesn't make the string longer than intended. ''' assert_matches('^[ABC@]{5}$', self.rs.rstr('ABC', 5, include='@')) def test_exclude(self) -> None: for _ in range(0, 100): assert 'C' not in self.rs.rstr('ABC', exclude='C') def test_include_as_list(self) -> None: assert_matches('^[ABC]*@[ABC]*$', self.rs.rstr('ABC', include=['@'])) def test_exclude_as_list(self) -> None: for _ in range(0, 100): assert 'C' not in self.rs.rstr('ABC', exclude=['C'])
class TestRstr(unittest.TestCase): def setUp(self): self.rs = Rstr() def test_specific_length(self): assert re.match('^A{5}$', self.rs.rstr('A', 5)) def test_length_range(self): assert re.match('^A{11,20}$', self.rs.rstr('A', 11, 20)) def test_custom_alphabet(self): assert re.match('^A{1,10}$', self.rs.rstr('AA')) def test_alphabet_as_list(self): assert re.match('^A{1,10}$', self.rs.rstr(['A', 'A'])) def test_include(self): assert re.match('^[ABC]*@[ABC]*$', self.rs.rstr('ABC', include='@')) def test_exclude(self): for _ in xrange(0, 100): assert 'C' not in self.rs.rstr('ABC', exclude='C') def test_include_as_list(self): assert re.match('^[ABC]*@[ABC]*$', self.rs.rstr('ABC', include=["@"])) def test_exclude_as_list(self): for _ in xrange(0, 100): assert 'C' not in self.rs.rstr('ABC', exclude=['C'])