fixtures

Cypress - Typescript - How can i make my fixture variables global?

三世轮回 提交于 2021-02-10 17:49:22
问题 Fairly new to Cypress/Typescript etc, i want to grab a value from my fixture and make it usable for the 'perform search and verify returned header is correct' test. However i cant seem to access the variable from within my test, any help appreciated: Here's the values in my fixture: { "manufacturer": "Dyson", "product": "9kJ Hand Dryer" } Here's my code that creates an alias from the fixture and attempts to access the variable, but im getting the following error: Cannot find name 'manuTerm'

Rails testing - Fixtures for has_many associations

℡╲_俬逩灬. 提交于 2021-02-08 18:38:39
问题 I am new to unit testing and have a simple use case. There are 2 models: City , Resident . A City has_many Residents. I created 2 fixture yml files: cities.yml, residents.yml. residents.yml resident1: name: resident1 resident2: name: resident2 resident3: name: resident3 cities.yml city1: name: city1 residents: resident1, resident2, resident3 When I run a trivial test that should always pass, I get an error : Minitest::UnexpectedError: ActiveRecord::StatementInvalid: Mysql2::Error: Unknown

Rails testing - Fixtures for has_many associations

眉间皱痕 提交于 2021-02-08 18:30:51
问题 I am new to unit testing and have a simple use case. There are 2 models: City , Resident . A City has_many Residents. I created 2 fixture yml files: cities.yml, residents.yml. residents.yml resident1: name: resident1 resident2: name: resident2 resident3: name: resident3 cities.yml city1: name: city1 residents: resident1, resident2, resident3 When I run a trivial test that should always pass, I get an error : Minitest::UnexpectedError: ActiveRecord::StatementInvalid: Mysql2::Error: Unknown

Label references for associations

两盒软妹~` 提交于 2021-02-07 18:11:11
问题 Rails provides label references for associations in fixtures like this: ### in pirates.yml reginald: name: Reginald the Pirate monkey: george ### in monkeys.yml george: name: George the Monkey pirate: reginald This works great for not-namedspaced models, but I'm using namespaces, and so Rails gets confused, and want to insert the labels instead of the label references. Any workaround or fix known? 回答1: Fixtures.identify seems to be the only solution, not really beautiful but better than ids.

Label references for associations

北城余情 提交于 2021-02-07 18:06:40
问题 Rails provides label references for associations in fixtures like this: ### in pirates.yml reginald: name: Reginald the Pirate monkey: george ### in monkeys.yml george: name: George the Monkey pirate: reginald This works great for not-namedspaced models, but I'm using namespaces, and so Rails gets confused, and want to insert the labels instead of the label references. Any workaround or fix known? 回答1: Fixtures.identify seems to be the only solution, not really beautiful but better than ids.

Django fixtures save with default value

孤者浪人 提交于 2021-02-07 14:20:47
问题 I'm using Django 1.7 and I have a problem with my fixtures. I would like Django to use the default value or use the save() method to create unspecified values. Here are my current objects: # File: uuidable.py import uuid from django.db import models from django.utils.translation import ugettext_lazy as _ class Uuidable(models.Model): uuid = models.CharField(_('uuid'), blank=True, null=False, unique=True, max_length=64, default=uuid.uuid4()) # Tried here class Meta: abstract = True def save

How can request.param be annotated in indirect parametrization?

痞子三分冷 提交于 2021-01-07 06:57:05
问题 In the Indirect parametrization example I want to type hint request.param indicating a specific type, a str for example. The problem is since the argument to fixt must be the request fixture there seems to be no way to indicate what type the parameters passed through the "optional param attribute" should be (quoting the documentation). What are the alternatives? Perhaps documenting the type hint in the fixt docstring, or in the test_indirect docstring? @pytest.fixture def fixt(request):

How to use pytest-aiohttp fixtures with scope session

痞子三分冷 提交于 2021-01-02 06:07:10
问题 I am trying to write tests for aiohttp application. I am using pytest-aiohttp plugin. My intention is to initialize and run the application once before first test execution and tear down after all tests finished. pytest-aiohttp fixtures like 'loop', 'test_client' are very helpful but they have scope='function' which means I can not use them from my own fixture with scope='session'. Is there a way to workaround this? And if not then what would be a proper approach for achieving my goal without

Pytest capture not working - caplog and capsys are empty

纵饮孤独 提交于 2020-12-15 06:55:13
问题 I am trying to create unit tests for a logger, but - even though the events are logged - the caplog and capsys remain empty. What am I doing wrong? 回答1: It turned out that my logger had property propagate set to False . As a result, the events were not forwarded to LogCaptureHandler added by pytest to the root logger. Both caplog and capsys depend on LogCaptureHandler receiving the propagated events. 来源: https://stackoverflow.com/questions/61702794/pytest-capture-not-working-caplog-and-capsys