From eb6527078256853bf0f527d54ae623be31cb818f Mon Sep 17 00:00:00 2001 From: Simon Wiles Date: Fri, 28 Aug 2020 14:58:25 -0700 Subject: [PATCH] Test that exception is raised --- tests/test_create.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_create.py b/tests/test_create.py index 71dc549..fc8edc0 100644 --- a/tests/test_create.py +++ b/tests/test_create.py @@ -707,6 +707,15 @@ def test_insert_thousands_using_generator(fresh_db): assert 10000 == fresh_db["test"].count +def test_insert_thousands_raises_exception_wtih_extra_columns_after_first_100(fresh_db): + # https://github.com/simonw/sqlite-utils/issues/139 + with pytest.raises(Exception, match="table test has no column named extra"): + fresh_db["test"].insert_all( + [{"i": i, "word": "word_{}".format(i)} for i in range(100)] + + [{"i": 101, "extra": "This extra column should cause an exception"}], + ) + + def test_insert_thousands_adds_extra_columns_after_first_100_with_alter(fresh_db): # https://github.com/simonw/sqlite-utils/issues/139 fresh_db["test"].insert_all(