Questions tagged [asynctest]

15 questions
32
votes
4 answers

How to mock aiohttp.client.ClientSession.get async context manager

I have some troubles with mocking aiohttp.client.ClientSession.get context manager. I found some articles and here is one example that seems was working: article 1 So my code that I want to test: async_app.py import random from aiohttp.client import…
8
votes
1 answer

Why is jest.useFakeTimers not working with RxJs Observable delay

I'm wondering why jest.useFakeTimers is working with setTimeout but not with the delay operator of RxJs: jest.useFakeTimers(); import {Observable} from 'rxjs/Observable'; import 'rxjs'; describe('timers', () => { it('should resolve setTimeout…
blockwork
  • 185
  • 1
  • 10
4
votes
0 answers

Python asynctest mock patch decorator spilling into subsequent tests

I am trying to test an async function. For this i am using pytest-asyncio and asynctest. I need to check how many times a function that is being used inside the function that i am testing is called. For this i am mocking the internal function using…
2
votes
1 answer

How asynctest.TestCase.setUp can be overridden by both async and sync methods?

I am writing a unit test that inherits from asynctest.TestCase and would like to create some mixins that perform an asynchronous setUp before each test case: import asynctest class Mixin1(object): async def setUp(self): await…
thesamet
  • 6,382
  • 2
  • 31
  • 42
1
vote
3 answers

How to set a timeout for Async suite in Scalatest?

Consider the following unit test example: class MySpec extends AsyncFlatSpec { "this" should "fail after some timeout" in { val resultFuture: Future[_] = Promise().future for (result <- resultFuture) yield { assert(result ==…
Alex Vayda
  • 6,154
  • 5
  • 34
  • 50
1
vote
1 answer

address already in use in async client tests in python

I have a question about async client tests. Here is my code about my test class TestSocketClient: @classmethod def setup_class(cls): # enable parallel testing by adding the pytest worker id number to the default port …
zhen404
  • 111
  • 1
  • 7
1
vote
1 answer

Testing Async Coroutines With Context Manager

I have been trying to test a Context managed Async coroutine through aiobotocore in Python 3.7 . I have been using the asynctest package to get the included MagicMock which has the magic methods of __aenter__ and __aexit__ and a custom mock factory…
JSwordy
  • 169
  • 1
  • 2
  • 13
1
vote
1 answer

Mocking aiohttp ClientSession contextmanager using asynctest

I have the following async function: async def my_func(request): # preparation code here with aiohttp.ClientSession() as s: with s.post(url, headers) as response: status_code = response.status if status_code…
Apostolos
  • 7,763
  • 17
  • 80
  • 150
0
votes
1 answer

Pact Async Consumer Test is failing with message null

I am testing to create a Async Pact for a test application, that uses RabbitMQ I got the application running but the test to create the pact fails with the following error. %TESTS …
0
votes
0 answers

Testing FastAPI database with async connection

I have application on FastAPI. For sending queries to db I'm using SQLAlchemy. Connection in my app looks like ` import databases from sqlalchemy import create_engine from sqlalchemy.orm import declarative_base from settings import…
0
votes
1 answer

MockServer with test specific session id

I use SpringBoot and Java to write e2e tests for my API. Along the flow, I am doing an HTTP call to a storage API (S3), and I am mocking it using MockServer. This is the HttpClient and how I am creating my post request: public class HttpClient { …
0
votes
1 answer

Converting test project from AMD to ES6 causes issue Qunit Asynctest cases

I am migrating/converting my test utilities project to ES6. I am using "@types/qunit": "^2.0.31" version to execute async test cases. All went well before conversion but after conversion asyncTest cases are not executing, its look like its not…
Aamir
  • 345
  • 4
  • 24
0
votes
2 answers

Test React function components promises behaviour with Jest,

I have a React function component. I pass a function to the component as a prop, that returns a promise. I use that function on an onClick event and once the promise is resolved, I change the state of the component. Something like: import React, {…
manosagent
  • 614
  • 8
  • 18
0
votes
1 answer

attribute error: 'nonetype' object has no attribute 'empty' for async await

class a(self): async def x(self, p1, p2): await connection.fetch(p1) .... return df async def y(self, p3, p4): df = await self.x(x1, x2) if not df.empty: # code How to write a test method for y()? After mock of…
pooh_go
  • 1
  • 2
0
votes
1 answer

async testing in rust - how to fail a test from a side thread or by panic

My library spawns a side thread and I'm trying to write unit tests for it. if the library/mocks panic I would like to fail the test. I'm mocking with mockall my lib code is something like: #[cfg_attr(test, automock)] trait T1 { fn foo(&self,…
Avba
  • 14,822
  • 20
  • 92
  • 192