Open sandcha opened 1 month ago
I think a good first step to avoid this error happening could be to add the --country-package command in the documentation (Running a test, end of the page). Another possibility is to force the use of the option if there are several openfisca packages in the environment to have an explicit error (until now, there is only a warning).
@sylvainipp Do you remember how you ended up with 2 country packages in the same environment? Was it intentional or an unseen side effect of some documentation that you followed?
I had first this kind of problem with openfisca-france-data, that requires to have also openfisca-france in the environment. And then, because of a test environment with several country packages, but intentionnally, and there is no reason to tackle this test case I think. I also needed openfisca-country-template to use some functionnality with openfisca-senegal, but I don't remember why exactly.
I forgot that we already added a warning : WARNING:openfisca_core.scripts:Several country packages detected :
openfisca_country_template, openfisca_france. Using
openfisca_country_templateby default. To use another package, please use the --country-package option.
But it didn't show up in the example above (open "🧐 " section in the description above to see the full stack trace).
Here is a simple test on openfisca_country_template
:
- name: test something
period: 2023-01
input:
accommodation_size: 20
output:
housing_allowance: 123
It displays the warning at the top of the trace with: openfisca test country-template/test_keynames.yaml
In this context:
OpenFisca-Core 41.4.7
openfisca-country_template 7.1.1
OpenFisca-France 167.1.0
The warning shows up at the beginning of the log, I think it wasn't on the screenshot but above (or at least, it was the case for me).
Hi there!
I really enjoy OpenFisca, but I recently encountered an issue.
Here is what a user did:
He installed
openfisca-france (v167.1.0)
and an other country package (likeopenfisca-country-template
) and tried to run a YAML test:Here is what we expected to happen:
We expected age.yaml execution result to be successful or to get an explicit error if the used command was not right.
Here is what actually happened:
AttributeError: 'NoneType' object has no attribute 'tracer'
is raised onopenfisca_core/tools/test_runner.py:262
.This error message is also disturbing in a context where we didn't ask for trace (aka openfisca test
--verbose
option).🧐 See full stack trace...
```shell ============================================================================= test session starts ============================================================================= platform darwin -- Python 3.10.6, pytest-7.4.4, pluggy-1.5.0 rootdir: /Users/sch/dev/gitruc/openfisca-france configfile: setup.cfg collected 12 items tests/formulas/age.yaml ..F ================================================================================== FAILURES =================================================================================== ________________________________________________________________________________ test session _________________________________________________________________________________ self =Here is data (or links to it) that can help you reproduce this issue:
It's possible to "force" the issue by giving a country package different from the current directory and test module with, for example:
And I remember that when
openfisca test
needs to choose between multiple installed packages, its behavior is inherited frompytest
. Looking into this line in openfisca-core might explain how it works under the hood.Even if our use case is unconsistent (running a test of a module on a different module might be a kind of issue that we will never completely guess in openfisca-core), we might be able to give some hints to the user. A minimal one could be adding the name of the country package to the error message.
Context
I identify more as a: