fixtures

Using a fake mongoDB for pytest testing

不羁岁月 提交于 2020-02-21 12:53:10
问题 I have code that connects to a MongoDB Client and I'm trying to test it. For testing, I don't want to connect to the actual client, so I'm trying to figure out make a fake one for testing purposes. The basic flow of the code is I have a function somewhere the creates a pymongo client, then queries that and makes a dict that is used elsewhere. I want to write some tests using pytest that will test different functions and classes that will call get_stuff . My problem is that get_stuff calls

Using a fake mongoDB for pytest testing

孤人 提交于 2020-02-21 12:51:49
问题 I have code that connects to a MongoDB Client and I'm trying to test it. For testing, I don't want to connect to the actual client, so I'm trying to figure out make a fake one for testing purposes. The basic flow of the code is I have a function somewhere the creates a pymongo client, then queries that and makes a dict that is used elsewhere. I want to write some tests using pytest that will test different functions and classes that will call get_stuff . My problem is that get_stuff calls

Using a fake mongoDB for pytest testing

非 Y 不嫁゛ 提交于 2020-02-21 12:51:33
问题 I have code that connects to a MongoDB Client and I'm trying to test it. For testing, I don't want to connect to the actual client, so I'm trying to figure out make a fake one for testing purposes. The basic flow of the code is I have a function somewhere the creates a pymongo client, then queries that and makes a dict that is used elsewhere. I want to write some tests using pytest that will test different functions and classes that will call get_stuff . My problem is that get_stuff calls

Doctrine fixtures - circular references

别来无恙 提交于 2020-02-01 04:15:51
问题 Is there any way to load fixtures that have circular referencing? As an example I have the following fixture: BusinessEntityTeam: Nicole_Team: name: Nicole's Team Manager: [Nicole] Business: [ACMEWidgets] sfGuardUser Nicole: first_name: Nicole last_name: Jones email_address: nicole@example.com username: nicole password: nicole Groups: [Group_abc] Team: [Nicole_Team] As you can see, Nicole_Team references Nicole... but Nicole also references Nicole_Team. When Manager wasn't a required column

Ember fixtures not working

懵懂的女人 提交于 2020-01-23 18:38:09
问题 This is my code (using ember-cli): app.coffee `import Ember from 'ember'` `import Resolver from 'ember/resolver'` `import loadInitializers from 'ember/load-initializers'` Ember.MODEL_FACTORY_INJECTIONS = true App = Ember.Application.extend modulePrefix: 'dashboard' # TODO: loaded via config Resolver: Resolver loadInitializers App, 'dashboard' `export default App` adapters/application.coffee `import DS from 'ember-data'` ApplicationAdapter = DS.FixtureAdapter.extend() `export default

Define a pytest fixture providing multiple arguments to test function

℡╲_俬逩灬. 提交于 2020-01-20 06:47:47
问题 With pytest, I can define a fixture like so: @pytest.fixture def foo(): return "blah" And use it in a test like so: def test_blah(foo): assert foo == "blah" That's all very well. But what I want to do is define a single fixture function that "expands" to provide multiple arguments to a test function. Something like this: @pytest.multifixture("foo,bar") def foobar(): return "blah", "whatever" def test_stuff(foo, bar): assert foo == "blah" and bar == "whatever" I want to define the two objects

Define a pytest fixture providing multiple arguments to test function

懵懂的女人 提交于 2020-01-20 06:47:26
问题 With pytest, I can define a fixture like so: @pytest.fixture def foo(): return "blah" And use it in a test like so: def test_blah(foo): assert foo == "blah" That's all very well. But what I want to do is define a single fixture function that "expands" to provide multiple arguments to a test function. Something like this: @pytest.multifixture("foo,bar") def foobar(): return "blah", "whatever" def test_stuff(foo, bar): assert foo == "blah" and bar == "whatever" I want to define the two objects

Load seed data in Rails 3 Project

耗尽温柔 提交于 2020-01-15 03:40:08
问题 Till now, i have been using Fixtures, along with a rake task to create some seed data for my database. This worked well, but i suddenly have weird problems(like getting autogen ids of 1,2,3.. in a model and then wrong ids in the join model, making the association not work at all). Thus, i was wondering what a better alternative is. I've read about different things, as well as the railscast on seeding data. My data does not really share same pieces of information. It's like separate entries

Doctrine fixtures not working after updating to Symfony 2.1.8

不羁的心 提交于 2020-01-15 03:34:11
问题 After updating a project from Symfony 2.0.22 to 2.1.8 I get this error when executing doctrine:fixtures:load via Terminal Fatal error: Class 'Doctrine\Common\DataFixtures\Loader' not found in {symfony_install_folder}/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/DataFixtures/ContainerAwareLoader.php on line 27 The fixtures worked on 2.0.22 and I've checked the official documentation to see if I've set everything correctly My composer.json looks like this: { "name": "symfony/framework

Running the same test on two different fixtures

柔情痞子 提交于 2020-01-13 08:31:31
问题 I have a test which currently runs with a single fixture like this: @pytest.fixture() def foo(): return 'foo' def test_something(foo): # assert something about foo Now I am creating a slightly different fixture, say @pytest.fixture def bar(): return 'bar' I need to repeat the exact same test against this second fixture. How can I do that without just copy/pasting the test and changing the parameter name? 回答1: Beside the test generation, you can do it the "fixture-way" for any number of sub