Python

Python

Python How to define a custom exception with parameters

How can a custom exception be defined in Python? If you check the error message to handle differently depending on the error, a different type of exception should be used. This post shows you some examples.
Python

Python How to use fixture in pytest to share a function

How can we write when we want to add a function that is executed for all tests, e.g. pre-process and post-process? If you want to know how to use fixture, this post is for you.
Python

Python Set value for many properties if it is not None

It is not good to write Null check as many properties as we need. It should be written in a single place. Define a function and call it for the necessary properties.
Sponsored links
Python

Python Reconstruct dictionary by splitting a formatted key string

The module that I used returned a dictionary but it didn't have any nested objects. It looks like this below. data =...
Docker

Python install Poetry in Docker container with VSCode

It took me a while to find out how to poetry install in Docker container with VSCode. So, I wrote this article for othe...
Python

Python mockito to stub an object for unit testing

mockito in Python doesn't have good documentation due to poor examples. I struggled with it to learn how to do something. If you also in the same situation, this post is for you. Stub, replace a method behavior, and verify the parameters!
Python

Python join function that works for list of list with non-string values

It occurs an error when join function is called with the following values. # TypeError: sequence item 0: expected st...
Python

Python Three ways to flatten a list

There seems not to be a built-in function to flatten a list in Python. So I implemented it. List containing lists th...
Python

Python How to pass a list to parametrize in Pytest

I searched for a way to pass a list as a parameter but I didn't find the answer. Because it is too easy to do...? Pa...
Python

Python How to call a function for all elements of a list by using map

If a function needs to be processed for all elements of a list, map function can be used. Basic usage of map functio...
Copied title and URL