From c7e5dd64513c0ec2b2df4c51c8df924c282417f9 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 27 Oct 2020 09:26:01 -0700 Subject: [PATCH] Applied latest Black --- sqlite_utils/db.py | 7 ++++- tests/test_m2m.py | 70 ++++++++++++++++++++++++---------------------- 2 files changed, 43 insertions(+), 34 deletions(-) diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index 0a16380..877c17f 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -1773,7 +1773,12 @@ class Table(Queryable): return pk def m2m( - self, other_table, record_or_iterable=None, pk=DEFAULT, lookup=None, m2m_table=None + self, + other_table, + record_or_iterable=None, + pk=DEFAULT, + lookup=None, + m2m_table=None, ): if isinstance(other_table, str): other_table = self.db.table(other_table, pk=pk) diff --git a/tests/test_m2m.py b/tests/test_m2m.py index 33cd0a8..cbc9015 100644 --- a/tests/test_m2m.py +++ b/tests/test_m2m.py @@ -31,16 +31,16 @@ def test_insert_m2m_list(fresh_db): humans.rows ) assert [ - ForeignKey( - table="dogs_humans", column="dogs_id", other_table="dogs", other_column="id" - ), - ForeignKey( - table="dogs_humans", - column="humans_id", - other_table="humans", - other_column="id", - ), - ] == dogs_humans.foreign_keys + ForeignKey( + table="dogs_humans", column="dogs_id", other_table="dogs", other_column="id" + ), + ForeignKey( + table="dogs_humans", + column="humans_id", + other_table="humans", + other_column="id", + ), + ] == dogs_humans.foreign_keys def test_insert_m2m_iterable(fresh_db): @@ -60,23 +60,27 @@ def test_insert_m2m_iterable(fresh_db): assert {"platypuses", "humans", "humans_platypuses"} == set(fresh_db.table_names()) humans = fresh_db["humans"] humans_platypuses = fresh_db["humans_platypuses"] - assert [{"humans_id": 1, "platypuses_id": 1}, {"humans_id": 2, "platypuses_id": 1}] == list( - humans_platypuses.rows - ) + assert [ + {"humans_id": 1, "platypuses_id": 1}, + {"humans_id": 2, "platypuses_id": 1}, + ] == list(humans_platypuses.rows) assert [{"id": 1, "name": "Phineas"}, {"id": 2, "name": "Ferb"}] == list( humans.rows ) assert [ - ForeignKey( - table="humans_platypuses", column="platypuses_id", other_table="platypuses", other_column="id" - ), - ForeignKey( - table="humans_platypuses", - column="humans_id", - other_table="humans", - other_column="id", - ), - ] == humans_platypuses.foreign_keys + ForeignKey( + table="humans_platypuses", + column="platypuses_id", + other_table="platypuses", + other_column="id", + ), + ForeignKey( + table="humans_platypuses", + column="humans_id", + other_table="humans", + other_column="id", + ), + ] == humans_platypuses.foreign_keys def test_m2m_with_table_objects(fresh_db): @@ -100,16 +104,16 @@ def test_m2m_lookup(fresh_db): assert people_tags.exists() assert tags.exists() assert [ - ForeignKey( - table="people_tags", - column="people_id", - other_table="people", - other_column="id", - ), - ForeignKey( - table="people_tags", column="tags_id", other_table="tags", other_column="id" - ), - ] == people_tags.foreign_keys + ForeignKey( + table="people_tags", + column="people_id", + other_table="people", + other_column="id", + ), + ForeignKey( + table="people_tags", column="tags_id", other_table="tags", other_column="id" + ), + ] == people_tags.foreign_keys assert [{"people_id": 1, "tags_id": 1}] == list(people_tags.rows) assert [{"id": 1, "name": "Wahyu"}] == list(people.rows) assert [{"id": 1, "tag": "Coworker"}] == list(tags.rows)