Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Peter Bittner
    @bittner
    You're probably running Python 2.7, and you'll need an (empty) __init__.py file in the folder you do the relative import. Doing just import zotero should work too, though, if it's in the same folder.
    Emiliano Heyns
    @retorquere
    I'm using python 3.7
    (and it's indeed in the same folder)
    (and I also have the empty init.py in the steps dir)
    Emiliano Heyns
    @retorquere
    That should have been __init__.py
    Peter Bittner
    @bittner
    Difficult to tell. Can you post a directory tree listing to make it easier to analyze?
    Emiliano Heyns
    @retorquere
    $ find features -type f
    features/steps/zotero.py
    features/steps/steps.py
    features/steps/__init__.py
    features/steps/preferences.toml
    features/steps/__pycache__/environment.cpython-37.pyc
    features/steps/__pycache__/zotero.cpython-37.pyc
    features/steps/__pycache__/__init__.cpython-37.pyc
    features/steps/environment.py
    features/environment.py
    features/import.feature
    features/export.feature
    Peter Bittner
    @bittner
    Your implementation looks a bit scary. Don't mess with environment.py. It should look clean and just contain what Behave needs to run. Take a look at this example: behave-django / tests / acceptance / environment.py (you don't need django_ready)
    Emiliano Heyns
    @retorquere
    I'm fully on board with that, but then I need a way to load other modules I write, which is what I'm struggling with.
    Emiliano Heyns
    @retorquere
    That sample from behave-django loads python code from tests/test_app/, while the behave tests live in tests/acceptance. I don't see that in one of the layout variants in the docs -- must I do something specific to set up something like this?
    Peter Bittner
    @bittner
    I don't think you have. We specify paths in the behave configuration, but this is mainly because we have BDD tests in two different places.
    Emiliano Heyns
    @retorquere
    I see. Then I really don't know what I'm doing wrong; I really want to clean up environment.py and steps.py, but for that I need to split off code for driving the client. I can do that locally by starting with PYTHONPATH=$PYTHONPATH:$(pwd)/features/steps behave but that seems strange, and (perhaps unrelatedly) that failed when I tried it on Travis, saying it couldn't find the module.
    Emiliano Heyns
    @retorquere
    I can see that PathManager manipulates sys.path -- is that the code that adds features/steps to sys.path for the duration of the run?
    Emiliano Heyns
    @retorquere
    I've been going through the django example posted here -- is it correct that if I were to add tests in paths in behave.ini, and have an __init__.py in tests, behave would load features from tests/features and tests/stuff.py would be importable as tests.stuff, or perhaps stuff? I see context-urlhelper.py importing from test_app.models import BehaveTestModel, and tests/test_app is named in tox.ini of the project.
    Peter Bittner
    @bittner
    That will work.
    Emiliano Heyns
    @retorquere
    Indeed it does. Fantastic, that will allow me to clean up steps.py
    In the docs for custom formatters, I see Formatter must be importable from python search path.. Is that the general python search path, or the python search path with the paths from behave.ini added?
    Emiliano Heyns
    @retorquere
    Can I expect after_all to run if I abort the test run (using ctrl-C)? I currently use atexit for cleaning up resources.
    IronforgeV
    @IronforgeV
    Hello! Question about fixtures, I have 2 fixtures I used to create/destroy resources, they each work individually, but if I nest one inside another, the outer one's cleanup doesn't get called, what am I missing?
    jenisys
    @jenisys
    @IronforgeV
    The „use_fixture(...)“ ensures that the cleanup/teardown part of the fixture(s) is called. Provide a simple example how you actually use the fixtures and perform the nesting.
    IronforgeV
    @IronforgeV
    @jenisys I'm using one fixture in before scenario, then another fixture in a step inside the scenario, the fixture for the scenario doesn't cleanup
    def before_scenario(context, scenario):
        """
        Hanlder before the test scenario is run
        """
        logging.info("Starting Scenario: %s", scenario.name)
        if scenario.name == 'Test PGaaS Product':
           use_fixture(provision_product, context)
    
    
    @capture
    def before_step(context, step):
        """
        Handler before the test step is run
        """
        logging.info("Starting Step: %s", step.name)
        if step.name == 'Create a clone of the cluster':
            use_fixture(provision_clone, context)
    IronforgeV
    @IronforgeV
    @jenisys my bad, I overwrote the context attribute that holds the resource id in the provisioning fixture class, so it tried to terminate the same resource twice
    Ljancek
    @Ljancek
    Hi, can I have one question? How can I attache python custom logger in to allure report when I'm using behave + python3 + selenium?
    Peter Bittner
    @bittner
    You better ask the friends over at Allure. https://docs.qameta.io/allure/#_get_help
    senthil kumar
    @senthilkumar369
    Hi Friends, i am looking for solutions for couple of issues. 1. how to read only a selected row from scenario outline examples. i f my scenario has 5 rows of data and i want to run my test for 4th row of data. How can i achieve it?
    i tried to see it is working or not but no luck
    for row in context.example:
        print(row)
    @given('a set of specific users{name}{department}')
    def TC_028_001(context,name,department):
    for row in context.example:
    print(row)
    i am getting an error that " AttributeError: 'Context' object has no attribute 'example'"
    senthil kumar
    @senthilkumar369
    please assist me
    this is for Behave BDD
    senthil kumar
    @senthilkumar369
    @mathewtrivett Are you able to get the rows from examples
    jenisys
    @jenisys
    The easiest way is to use the FileLocation (Schema: filename:line_number) with the line number of the row. For example: ˋfeatures/Alice.feature:123ˋ where ˋ123ˋ is the line number of the Examples row. Otherwise, use a row_id tag in the ScenarioOutline to select the Scenario for the Examples row by tag. See New and Noteworthy: ScenarioOutline Improvements and Appendix: Context Attributes — active_outline
    Hint: During runtime you normally do not see the ScenarioOutline only the generated Scenarios from it, one per Examples row.
    senthil kumar
    @senthilkumar369
    Thanks @jenisys , i will try and let you know
    senthil kumar
    @senthilkumar369
    Hi @ jenisys , I have examples which has 100 rows. is there anyway to read from external file?
    i can read from external file using python but cant write back to the desired step
    please advise
    jenisys
    @jenisys
    You can use behave @listfile.txt which reads the list of feature files of FileLocations from the textual file „listfile.txt“. But if you want to run all examples of a ScenarioOutline or the complete ScenarioOutline, why do you not use tags ? Your initial question was that you want to run one Example row in a ScenarioOutline.
    senthil kumar
    @senthilkumar369
    @jenisys Sorry it is my mistake. I wanted to ask about the data which is under Scenario outline examples. if my scenario outline's example contains 50 to 100 datas that should be tested. i am keeping all in a feature file.
    is there a way to read those parameters from csv or excel
    jenisys
    @jenisys
    @senthilkumar369
    Sorry, currently not. If you need this feature now, I would generate the feature files from a template (for example: Jinja) with the data from the CSV files. Otherwise, see: Github issues #636 (@table_generator.from_file mentioned). Note that by using so many example rows, you are using behave for system tests or integration tests (not for ATDD or BDD) ?!?
    senthil kumar
    @senthilkumar369
    @jenisys you are right however need to test different parameters. I know that it can be read through python however dont know how to write back to steps, so that i can see it on desired step
    Could you please tell me any ways
    jenisys
    @jenisys
    I have already told you my preferred solution.
    senthil kumar
    @senthilkumar369
    hI @jenisys , how to use "@table_generator.from_file" in my feature file. i have created a json file which has table column names . i want to pass it to my test script
    @at_028
    Scenario:Validate Parameter can be written with L1 key
    When TC_028 Authenticate with L1 KEY
    Then should be able to write Parameter
    @table_generator.from_file=L1_Parameters.json
    | Param_Name |MemoryAddress|Expected|