Comments (10)
Thanks for reporting this problem in such a great detail!
This might be related to what @sebastianmanger explains in #66 (comment). Could you take a look?
I'm not sure if this feature ever worked, hmmm. We need to get it working now.
from behave-django.
@Exanis
The behave step decorator @given(...)
registers the function object in the step registry.
Therefore, I assume that you need to change the order of the decorators to fix the problem, like:
@given('a default project database exist')
@fixtures("test_project.json")
def project_database(context):
pass
Have you tried this ?
from behave-django.
@jenisys Unfortunately, swapping the decorator order doesn't change anything about the failing tests. At least in the behave_django
code base.
from behave-django.
@bittner I agree, it seems to be the same problem :)
If that may help to fix / help people with the same problem that I have, I did this workaround:
- Create a step like this:
@given("i load fixture (?P<fixture>.+)")
def load_fixture(context, fixture):
pass
As you can see, this step basically do nothing but allow me to get a fixture and have a common sentence for this. Then I added to my environment.py
def django_ready(context):
for step in context.scenario.all_steps:
match = re.match(r"i load fixture (?P<fixture>.+)", step.name)
if match:
if not context.test.fixtures:
context.test.fixtures = []
context.test.fixtures.append(match.group('fixture'))
context.test._fixture_setup()
The feeling is not really "behavish" as it is, because I end up with steps like:
"Given i load fixture test_project.json"
I didn't change much more than that since I'm using it for an API, so everybody who do write those tests do know what a json is ; but it could be better to change it a bit to avoid adding the ".json", that would make it more "readable" from a non-tech point of view.
from behave-django.
This happens because of the issue discussed in #66
I didn't reply, as I am having a fever these days. I can probably look into it next week.
@Exanis maybe this will help for the moment: https://behave.readthedocs.io/en/latest/fixtures.html
from behave-django.
@sebastianmanger Do you have time to look into fixing this issue this weekend?
from behave-django.
I did some digging, here's my findings:
- The registry of steps (provided by behave) is populated after the call to 'setup_fixtures', fixture loading depends on the registry.
- I am not familiar with the internals of behave / registering the steps. But one approach may be to load steps from within behave-django.
- Another approach may be to use djangos module loading helper to import all decorators from the steps.
As I am more familiar with django than with behave, I would tend to implement the latter. I can look into it, just expect some lag... If someone else can do it, all the better!
from behave-django.
@sebastianmanger, please go ahead with the route that is easiest for you. It's of great help! 👍
@jenisys any suggestions or concerns?
from behave-django.
@sebastianmanger @bittner
Pull-request #72 should fix the problem (IMHO).
from behave-django.
from behave-django.
Related Issues (20)
- Documentation of django_ready hook incorrectly lists "scenario" as a second positional argument HOT 2
- Fixtures silently do nothing when --simple is specified, and no documentation calls this out HOT 10
- Getting more programmatic flexibility on the testcase type used in scenarios HOT 4
- Cleanup of custom permissions between scenarios HOT 1
- multiple features and before_all initial setup HOT 2
- how to assess test case code coverage? HOT 5
- Testing ASGI Django HOT 5
- Custom Runner e TestCase HOT 19
- Add support for customized LiveServerTestCase with selenium-hub support HOT 1
- Support latest stable version of Python and Django
- Use GitHub Actions CI HOT 1
- Looking for (co-)maintainer! 🔥🙏🦠🔥🐍 HOT 3
- Tables are not created for test_database while running behave test HOT 3
- Investigate potential bug in `environment.get_url()`
- Inconsistent when using behave --simple HOT 1
- Objects not only being created in test database
- Behave v1.2.7.dev3 breaks management command HOT 5
- NEEDS: .readthedocs.yaml config-file soon (before 2023-09) HOT 1
- Coverage advice breaks m2m queries. HOT 2
- Dependency on Behave blocks release on PyPI
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from behave-django.