コード例 #1
0
    def test_unlimited(self):
        s = Strings()

        for v in self.strings:
            s.validate(v)

        for v in self.not_strings:
            with self.assertRaises(TypeError):
                s.validate(v)

        self.assertEqual(repr(s), '<Strings>')
コード例 #2
0
ファイル: test_string.py プロジェクト: yuiponpon/Qcodes
def test_unlimited():
    s = Strings()

    for v in strings:
        s.validate(v)

    for v in not_strings:
        with pytest.raises(TypeError):
            s.validate(v)

    assert repr(s) == '<Strings>'
コード例 #3
0
    def test_max(self):
        for max_len in [1, 5, 10, 100]:
            s = Strings(max_length=max_len)
            for v in self.strings:
                if len(v) <= max_len:
                    s.validate(v)
                else:
                    with self.assertRaises(ValueError):
                        s.validate(v)

        for v in self.not_strings:
            with self.assertRaises(TypeError):
                s.validate(v)

        self.assertEqual(repr(s), '<Strings len<=100>')
コード例 #4
0
ファイル: test_string.py プロジェクト: yuiponpon/Qcodes
def test_max():
    for max_len in [1, 5, 10, 100]:
        s = Strings(max_length=max_len)
        for v in strings:
            if len(v) <= max_len:
                s.validate(v)
            else:
                with pytest.raises(ValueError):
                    s.validate(v)

    for v in not_strings:
        with pytest.raises(TypeError):
            s.validate(v)

    assert repr(s) == '<Strings len<=100>'
コード例 #5
0
    def test_range(self):
        s = Strings(1, 10)

        for v in self.strings:
            if 1 <= len(v) <= 10:
                s.validate(v)
            else:
                with self.assertRaises(ValueError):
                    s.validate(v)

        for v in self.not_strings:
            with self.assertRaises(TypeError):
                s.validate(v)

        self.assertEqual(repr(s), '<Strings 1<=len<=10>')

        # single-valued range
        self.assertEqual(repr(Strings(10, 10)), '<Strings len=10>')
コード例 #6
0
ファイル: test_string.py プロジェクト: yuiponpon/Qcodes
def test_range():
    s = Strings(1, 10)

    for v in strings:
        if 1 <= len(v) <= 10:
            s.validate(v)
        else:
            with pytest.raises(ValueError):
                s.validate(v)

    for v in not_strings:
        with pytest.raises(TypeError):
            s.validate(v)

    assert repr(s) == '<Strings 1<=len<=10>'

    # single-valued range
    assert repr(Strings(10, 10)) == '<Strings len=10>'
コード例 #7
0
 def test_valid_values(self):
     val = Strings()
     for vval in val.valid_values:
         val.validate(vval)
コード例 #8
0
 def test_valid_values(self):
     val = Strings()
     val.validate(val.valid_values[0])