pytest-dev / pytest-bdd

BDD library for the py.test runner
https://pytest-bdd.readthedocs.io/en/latest/
MIT License
1.3k stars 219 forks source link

pytest-bdd should be internationalized #179

Open jangeroo opened 8 years ago

jangeroo commented 8 years ago

Cucumber, Behave, and other BDD tools allow you to write your feature files in just about whatever language you want. It would be really handy to have the ability to use keywords other than the English versions.

A useful implementation would be one that allows anyone to create a new language file. Ideally it would also comes bundled with several language files for mainstream languages (i.e. French, Spanish, German, Russian, Chinese, etc.), though this is less useful than the ability to create a new custom language file.

olegpidsadnyi commented 8 years ago

Do you mean having possibility to translate: "Feature, Background, Scenario, Given, When, Then, And"? Can you provide some links where i can see how does it look like?

jangeroo commented 8 years ago

Yes. That's exactly what I mean :)

Here's the wiki for this feature from the cucumber project https://github.com/cucumber/cucumber/wiki/Translations

gilmrjc commented 8 years ago

+1

zaz600 commented 7 years ago

+1

AndersonFirmino commented 7 years ago

+1

bubenkoff commented 7 years ago

the whole thing can be done just by monkeypatching those https://github.com/pytest-dev/pytest-bdd/blob/master/pytest_bdd/types.py just make sure you monkeypatch it before calling scenario function

AndersonFirmino commented 7 years ago

@bubenkoff Can you show me an example?

bubenkoff commented 7 years ago

in the initpy of the tests folder:

from pytest_bdd import types

types.FEATURE = "italian feature" ....

simpoir commented 6 years ago

Actually, patching pytest_bdd.feature.STEP_PREFIXES would be slightly better, as you don't need to alter the types, but rather the parsing. And since a few of those translations are many-to-one-type.

e.g. according to https://github.com/cucumber/cucumber/blob/master/gherkin/gherkin-languages.json#L1138

from pytest_bdd.feature import STEP_PREFIXES
from pytest_bdd import types

STEP_PREFIXES[:] = []  # clear existing translations to avoid conflicts.
STEP_PREFIXES.append(("Quand ", types.WHEN))
STEP_PREFIXES.append(("Lorsque ", types.WHEN))
STEP_PREFIXES.append(("Lorsqu'", types.WHEN))
...
ghost commented 4 years ago

I have written this in the init.py file of the tests folder and I get a NoScenariosFound exception. Any idea what I did wrong?

TheoAndersen commented 3 years ago

@MichielPeeters7 In the current implementation of pytest-bdd, you can't just overwrite the STEP_PREFIXES or types, because they are loaded when the plugin loads.

This issue is perhaps duplicated by #397