Skip to content

Commit 39e72e5

Browse files
authored
Fix test_categories_as_list failing with peewee.OperationalError (#341)
Move test_categories_as_list into LCIATestCase2 (which uses BW2DataTest) so it runs with a properly configured temporary project. The standalone function had no bw2data project set up, causing peewee to fail when match_subcategories called Database(biosphere_db_name) internally.
1 parent c8d1bbf commit 39e72e5

1 file changed

Lines changed: 20 additions & 21 deletions

File tree

tests/strategies/lcia.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,26 @@ def test_match_subcategories_not_remove(self):
409409
]
410410
self.assertEqual(expected, match_subcategories(data, "b"))
411411

412+
def test_categories_as_list(self):
413+
"""issues/212 - categories given as list instead of tuple should not raise"""
414+
data = [
415+
{
416+
"name": "Method 1",
417+
"exchanges": [
418+
{
419+
"categories": [
420+
"air",
421+
],
422+
"name": "Emission",
423+
"unit": "kg",
424+
"amount": 1.0,
425+
},
426+
],
427+
}
428+
]
429+
biosphere_db_name = "example_biosphere"
430+
match_subcategories(data, biosphere_db_name) # should pass without traceback
431+
412432
def test_match_subcategories_makes_copies(self):
413433
"""Should copy data instead of creating references, so that there are different amounts for different methods."""
414434
self.maxDiff = None
@@ -459,27 +479,6 @@ def test_match_subcategories_makes_copies(self):
459479
self.assertEqual(cf["amount"], 2)
460480

461481

462-
def test_categories_as_list():
463-
"""issues/212"""
464-
data = [
465-
{
466-
"name": "Method 1",
467-
"exchanges": [
468-
{
469-
"categories": [
470-
"air",
471-
],
472-
"name": "Emission",
473-
"unit": "kg",
474-
"amount": 1.0,
475-
},
476-
],
477-
}
478-
]
479-
biosphere_db_name = "example_biosphere"
480-
match_subcategories(data, biosphere_db_name) # should pass without traceback
481-
482-
483482
def test_rationalize_method_names_no_remove_lt():
484483
given = [
485484
{"name": ("aw/o LT", "b", "c w/o LT")},

0 commit comments

Comments
 (0)