예제 #1
0
파일: test_box.py 프로젝트: cdgriffith/Box
    def test_dots(self):
        b = Box(movie_data.copy(), box_dots=True)
        assert b["movies.Spaceballs.rating"] == "PG"
        b["movies.Spaceballs.rating"] = 4
        assert b["movies.Spaceballs.rating"] == 4
        del b["movies.Spaceballs.rating"]
        with pytest.raises(BoxKeyError):
            b["movies.Spaceballs.rating"]
        assert b["movies.Spaceballs.Stars[1].role"] == "Barf"
        b["movies.Spaceballs.Stars[1].role"] = "Testing"
        assert b["movies.Spaceballs.Stars[1].role"] == "Testing"
        assert b.movies.Spaceballs.Stars[1].role == "Testing"
        with pytest.raises(BoxError):
            b["."]
        with pytest.raises(BoxError):
            from box.box import _parse_box_dots

            _parse_box_dots({}, "-")

        with pytest.raises(KeyError):
            b["a.b"]
        with pytest.raises(BoxKeyError):
            b["a.b"]

        with pytest.raises(KeyError):
            del b["a.b"]
        with pytest.raises(BoxKeyError):
            del b["a.b"]
예제 #2
0
파일: test_box.py 프로젝트: jkylling/Box
 def test_dots(self):
     b = Box(movie_data.copy(), box_dots=True)
     assert b['movies.Spaceballs.rating'] == "PG"
     b['movies.Spaceballs.rating'] = 4
     assert b['movies.Spaceballs.rating'] == 4
     del b['movies.Spaceballs.rating']
     with pytest.raises(BoxKeyError):
         b['movies.Spaceballs.rating']
     assert b['movies.Spaceballs.Stars[1].role'] == 'Barf'
     b['movies.Spaceballs.Stars[1].role'] = 'Testing'
     assert b['movies.Spaceballs.Stars[1].role'] == 'Testing'
     assert b.movies.Spaceballs.Stars[1].role == 'Testing'
     with pytest.raises(BoxError):
         b['.']
     with pytest.raises(BoxError):
         from box.box import _parse_box_dots
         _parse_box_dots('-')