Questions tagged [pyhamcrest]
7 questions
1
vote
2 answers
pyhamcrest - Compare two list
I've just started learning python. Currently writing a unit test to assert if the elements in the expected list is present in the actual list
def test_compare_list_of_items():
actual_list_of_items = ['a','b']
expected_list_of_items = ['a']
…

k10
- 62
- 1
- 7
1
vote
1 answer
pyhamcrest contains matcher for list of dicts
Why pyhamcrest is failing contains() matcher for list of 2 or more dicts, but works fine with list of 1 dict?
PyHamcrest contains
What is the best way to write hamcrest (pyhamcrest) matcher for list of dicts?
First test passed, second failed in this…

yeugeniuss
- 180
- 1
- 7
1
vote
1 answer
Why doesn't PyHamcrest have a negative equality matcher?
Reviewing PyHamcrest's API, I see there's an equal_to matcher
from hamcrest import *
assert_that('1', equal_to('1'))
but there's no parallel negative method such as not_equal_to
from hamcrest import *
assert_that('1', not_equal_to('2'))
What's the…

noamt
- 7,397
- 2
- 37
- 59
0
votes
1 answer
Pytest fails when using pyhamcrest raises
Currently I have a test cases like the following:
def test_foo(self):
assert_that(self.target.do(), raises(FileNotFoundError))
Which passes using the standard python unittest framework, however if I change to use pytest, it fails.…

Kingamajick
- 2,281
- 1
- 16
- 19
0
votes
1 answer
Python: Assert mock function was called with a string containing another string
Here is a simplified version of the problem I am facing: Let's say I have a function that accepts a path to a directory and then removes all of its content except (optionally) a designated "keep file",
import os
KEEP_FILE_CONSTANT = '.gitkeep'
def…

Grant Moore
- 153
- 1
- 10
0
votes
1 answer
hamcrest: how to input Boolean value
I am not sure why I see error when I have this code. all_is_valid is highlighted in yellow and when I hover over I see below error message. How do I avoid not highlighting it?
Expected type 'Matcher[bool]' (matched generic type 'Matcher[T]'), got…

Raj
- 368
- 1
- 5
- 17
0
votes
3 answers
This is my program when i return num_list it doesn't work but when i put print it work smoothly,
This is my program when i return num_list it doesn't work but when i put print it work smoothly,my program and another friend program is exactly same but his program working and mine not.
import random
def make_random_real():
num_list = []
…

Fazal Rehman
- 7
- 1
- 2