コード例 #1
0
    def test_eq(self):
        label1 = Label()
        label1.classification = Classification("cat", {"color": "white"})

        label2 = Label()
        label2.classification = Classification("cat", {"color": "white"})

        label3 = Label()
        label3.classification = Classification("cat", {"color": "black"})

        assert label1 == label2
        assert label1 != label3
コード例 #2
0
    def test_dumps(self):
        contents = {
            "CLASSIFICATION": {"category": "cat", "attributes": {"gender": "male"}},
            "BOX2D": [
                {
                    "box2d": {"xmin": 1, "ymin": 1, "xmax": 2, "ymax": 2},
                    "category": "dog",
                    "attributes": {"gender": "female"},
                }
            ],
        }

        label = Label()
        label.classification = Classification.loads(contents["CLASSIFICATION"])
        label.box2d = [LabeledBox2D.loads(contents["BOX2D"][0])]
        assert label.dumps() == contents
コード例 #3
0
    def test_bool(self):
        label = Label()
        assert bool(label) == False

        label.classification = Classification()
        assert bool(label) == True