testing

How to use pytest capsys on tests that have mocking decorators?

自闭症网瘾萝莉.ら 提交于 2020-02-24 14:40:13
问题 I have being trying to find a way to use mocking decorators and pytest capsys at the same time but I wasn't able to find the right way to do it. import pytest import requests_mock @requests_mock.mock() def test_with_mock(m): pass def test_with_capsys(capsys): pass # how to write a test that works with both? 回答1: As stated in the request-mock's docs: pytest has its own method of registering and loading custom fixtures. requests-mock provides an external fixture registered with pytest such that

Create React App cannot find tests

為{幸葍}努か 提交于 2020-02-24 04:18:45
问题 I recently started a new project using create-react-app. I moved the App.test.js from outside the /src folder into a root level /tests folder so my folder structure looks like this now: > node_modules > public > src ... App.js > tests App.test.js ... And here's the entire App.test.js file: import React from 'react'; import ReactDOM from 'react-dom'; import App from "../src/App"; it('renders without crashing', () => { const div = document.createElement('div'); ReactDOM.render(<App />, div);

Create React App cannot find tests

筅森魡賤 提交于 2020-02-24 04:18:07
问题 I recently started a new project using create-react-app. I moved the App.test.js from outside the /src folder into a root level /tests folder so my folder structure looks like this now: > node_modules > public > src ... App.js > tests App.test.js ... And here's the entire App.test.js file: import React from 'react'; import ReactDOM from 'react-dom'; import App from "../src/App"; it('renders without crashing', () => { const div = document.createElement('div'); ReactDOM.render(<App />, div);

RSpec - Undefined method `key?'

戏子无情 提交于 2020-02-23 07:18:18
问题 I'm trying to run a test for rendering templates and ran into the error: undefined method `key?' for 1014:Fixnum The stub of my model's instance works as it should in my route tests but not so much here. What am I doing wrong? describe RestaurantsController do let(:restaurant) { FactoryGirl.build_stubbed(:restaurant) } describe 'GET #show' do before { get :show, restaurant.id } it { should render_template('show') } end end Full Error 1) RestaurantsController GET #show Failure/Error: before {

How to add selenium test coverage for jquery autocompleter text field

落爺英雄遲暮 提交于 2020-02-23 05:35:33
问题 I have a text field , and jquery auto completer is binded to it. html <div id="autoCompleter"> <input type="text" name="symbol" /> </div> javascript $('#autoCompleter').delegate("input", "focus", AutoCompleter); var AutoCompleter = function(event) { $(this).autocomplete({ source: function(request, response) { jQuery.extAjax({ url: url, data: data, success: response }); }, select: function(event, ui) { if (ui.item.value.match(/^Enter more characters...$/)) { return false; } }, focus: function

How to add selenium test coverage for jquery autocompleter text field

守給你的承諾、 提交于 2020-02-23 05:34:46
问题 I have a text field , and jquery auto completer is binded to it. html <div id="autoCompleter"> <input type="text" name="symbol" /> </div> javascript $('#autoCompleter').delegate("input", "focus", AutoCompleter); var AutoCompleter = function(event) { $(this).autocomplete({ source: function(request, response) { jQuery.extAjax({ url: url, data: data, success: response }); }, select: function(event, ui) { if (ui.item.value.match(/^Enter more characters...$/)) { return false; } }, focus: function

How to add selenium test coverage for jquery autocompleter text field

无人久伴 提交于 2020-02-23 05:34:02
问题 I have a text field , and jquery auto completer is binded to it. html <div id="autoCompleter"> <input type="text" name="symbol" /> </div> javascript $('#autoCompleter').delegate("input", "focus", AutoCompleter); var AutoCompleter = function(event) { $(this).autocomplete({ source: function(request, response) { jQuery.extAjax({ url: url, data: data, success: response }); }, select: function(event, ui) { if (ui.item.value.match(/^Enter more characters...$/)) { return false; } }, focus: function

How to execute all tests in PHPUnit?

蓝咒 提交于 2020-02-23 03:50:29
问题 I'm trying run all tests from my testsuite, but PHPUnit not found the tests when I run command phpunit . I config testsuite in phpunit.xml. phpunit.xml <?xml version="1.0" encoding="UTF-8" ?> <phpunit backupGlobals="true" backupStaticAttributes="false" bootstrap="./bootstrap.php" cacheTokens="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" forceCoversAnnotation="false" mapTestClassNameToCoveredClassName="false"

How to execute all tests in PHPUnit?

情到浓时终转凉″ 提交于 2020-02-23 03:50:05
问题 I'm trying run all tests from my testsuite, but PHPUnit not found the tests when I run command phpunit . I config testsuite in phpunit.xml. phpunit.xml <?xml version="1.0" encoding="UTF-8" ?> <phpunit backupGlobals="true" backupStaticAttributes="false" bootstrap="./bootstrap.php" cacheTokens="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" forceCoversAnnotation="false" mapTestClassNameToCoveredClassName="false"

Asserting that __init__ was called with right arguments

对着背影说爱祢 提交于 2020-02-21 09:46:13
问题 I'm using python mocks to assert that a particular object was created with the right arguments. This is how my code looks: class Installer: def __init__(foo, bar, version): # Init stuff pass def __enter__(self): return self def __exit__(self, type, value, tb): # cleanup pass def install(self): # Install stuff pass class Deployer: def deploy(self): with Installer('foo', 'bar', 1) as installer: installer.install() Now, I want to assert that installer was created with the right arguments. This