fixtures

How to concatenate several parametrized fixtures into a new fixture in py.test?

时光总嘲笑我的痴心妄想 提交于 2019-11-30 02:51:16
问题 If I have two parametrized fixtures, how can I create a single test function that is called first with the instances of one fixture and then with the instances of the other fixture? I guess it would make sense to create a new fixture that somehow concatenates the two existing fixtures. This works well for "normal" fixtures, but I don't seem to get it to work with parametrized fixtures. Here is a simplified example of what I tried: import pytest @pytest.fixture(params=[1, 2, 3]) def lower

Automatic associations in ruby on rails fixtures

梦想的初衷 提交于 2019-11-30 01:22:07
问题 As described in this article, I am using automatic associations in fixtures. For example, if a region object has a country id, instead of doing "country_id": 1, I do "country": "USA". "USA" is a label in my countries.yml file, so fixtures knows how to take care of this. However, this only works when you do not specify an ID value for the countries object. So I cannot assign USA's ID to be 1. But if I do not assign it to be 1, it ends up being some large value 8974343...which is kinda strange.

Laravel DB Seeds - Test Data v Sample Data

删除回忆录丶 提交于 2019-11-29 21:16:43
问题 I'm probably misunderstanding exactly how this works, but what's the best way to accomplish this? I have something in mind but it seems quite hacky. I have a set of sample data which I use to test my application. This is seeded via the built in seeder in Laravel. This contains things like example users, addresses, documents etc. I also have a set of default data which should go in production. I currently add this directly in the migration. For example, if I was adding a table for account

What are fixtures in programming?

女生的网名这么多〃 提交于 2019-11-29 18:55:37
I heard this term many times before (when talking about programming) but couldn't find any explanation what does it mean. Any good articles or explanations? I didn't find anything worth mentioning. m01 I think you're referring to test fixtures : The purpose of a test fixture is to ensure that there is a well known and fixed environment in which tests are run so that results are repeatable. Some people call this the test context. Examples of fixtures: - Loading a database with a specific, known set of data - Erasing a hard disk and installing a known clean operating system installation -

Symfony 3.4.0 Could not find any fixture services to load

谁都会走 提交于 2019-11-29 03:04:18
I am using Symfony 3.4.0, I try to load fixtures with: php bin/console doctrine:fixtures:load An error occurred while creating the data, what's wrong? This command looks for all services tagged with doctrine.fixture.orm . There is two ways to fix this problem. First one: any class that implements ORMFixtureInterface will automatically be registered with this tag. <?php namespace AppBundle\DataFixtures\ORM; use Doctrine\Bundle\FixturesBundle\ORMFixtureInterface; use Doctrine\Common\Persistence\ObjectManager; class LoadFixtures implements ORMFixtureInterface { public function load(ObjectManager

Rails fixtures — how do you set foreign keys?

為{幸葍}努か 提交于 2019-11-29 02:54:10
I'm reading about Rails fixtures in this guide (thanks, trevorturk). It appears you define classes in a Yaml file and they're automatically loaded into the test DB -- cool. But if you want to specify that this recipe belongs to that cookbook (or whatever) how do you do that? Are you supposed to specify the values for cookbook.id and recipe.cookbook_id by hand in the Yaml code? (Just a guess -- the guide doesn't show anything like that.) Or is there a more suitable way? You should use named fixtures, which automatically generate an id number for you where you don't provide one. These id numbers

How and where does py.test find fixtures

 ̄綄美尐妖づ 提交于 2019-11-29 02:14:12
问题 Where and how does py.test look for fixtures? I have the same code in 2 files in the same folder. When I delete conftest.py, cmdopt cannot be found running test_conf.py (also in same folder. Why is sonoftest.py not searched? # content of test_sample.py def test_answer(cmdopt): if cmdopt == "type1": print ("first") elif cmdopt == "type2": print ("second") assert 0 # to see what was printed content of conftest.py import pytest def pytest_addoption(parser): parser.addoption("--cmdopt", action=

Loading Rails Fixtures in a Specific Order when Testing

不羁的心 提交于 2019-11-28 23:16:50
Is there a way to load Rails fixtures in a specific order while running tests? For example, take the following classes... class User < ActiveRecord::Base has_many :memberships has_many :groups, through: :memberships end class Group < ActiveRecord::Base has_many :memberships has_many :users, through: :memberships end class Membership < ActiveRecord::Base belongs_to :user belongs_to :group end Memberships have a database level foreign key constraint requiring Users and Groups to be present before they can be created. However, because Rails loads fixture alphabetically, Memberships are loaded

Rails Fixtures not loading with rspec

為{幸葍}努か 提交于 2019-11-28 22:55:56
So, I'm trying to learn the rspec BDD testing framework in the context of a rails project. The problem I'm having is that I can't, for the life of me, get my fixtures to load properly in rspec descriptions. Disclaimer: Yes, there are better things than fixtures to use. I'm trying to learn one thing at a time, here (specifically rspec) before I go play with associated tools like factory-girl, mocha, auto-test, etc. As such, I'm trying to get the dead-simple, if clunky, fixtures working. Anyway, here's the code: /test/fixtures/users.yml - # password: "secret" foo: username: foo email: foo

How to load sql fixture in Django for User model?

泪湿孤枕 提交于 2019-11-28 18:26:33
Does anyone knows how to load initial data for auth.User using sql fixtures? For my models, I just got have a < modelname >.sql file in a folder named sql that syncdb does it's job beautifully. But I have no clue how to do it for the auth.User model. I've googled it, but with no success. Thanks in advance, Aldo For SQL fixtures, you'd have to specifically have insert statements for the auth tables. You can find the schema of the auth tables with the command python manage.py sql auth . The much easier and database-independent way (unless you have some additional SQL magic you want to run), is