Python Unit Test

Unit Test A unit test verifies that one specific aspect of a function’s behavior is correct. If we have a main file with functions or just a file with functions we want to test different use cases, it is easier to use unittest rather then change the script and run it every time. Here us a function func_to_print_full_name in the func_file.py file: def func_to_print_full_name(first, last): full_name = first + ' ' + last return full_name Create a file (test_func....

December 16, 2021 · 2 min · Dmitry Golovach

Web: HTML - Select vs Datalist

Just found an interesting tag - , which allows to provide the list with options for user to select. I remember while building my web application I used select options and generated the list from some source. How it works with : <form> <div> <input name="country" list="countries" placeholder="Country"> <datalist id="countries"> <option value="Afghanistan"> <option value="Albania"> <option value="Algeria"> <option value="Andorra"> ... </datalist> </div> </form> Found the explanation: element - user must select one of the provided options element - it’s only the list with suggestions, but user can enter anything With <datalist> I can enter anything in there:...

December 8, 2020 · 1 min · Dmitry Golovach

\U0001F40D Python Logging

I decided to take a look into Python Logging and start using it instead of print(). Everything is here: Logging HOWTO. Task you want to perform The best tool for the task Display console output for ordinary usage of a command line script or program print() Report events that occur during normal operation of a program (e.g. for status monitoring or fault investigation) logging.info() (or logging.debug() for very detailed output for diagnostic purposes)...

May 26, 2020 · 3 min · Dmitry Golovach

Linux on Windows, Python IDE, and VirtualEnv

Linux on Windows For some tasks, it is still easier to use Windows (Cisco IP Communicator, UCCX Script Editor, CUCM RTMT, etc.), but there is an option to include Linux into the workflow. Recently I discovered the WLS: Windows Subsystem for Linux (WSL), which allows us to install and run sort of Linux on Windows10 side-by-side. Go to Microsoft Store and search for Linux: Get, Install and Launch: Set username and password and you are in Linux:)...

January 2, 2020 · 2 min · Dmitry Golovach

Python: Script structure

I decided to make some Python notes. Since there is a ton of information about Python, these notes will be mostly for my reference but if they help anyone - it will be great. The best way to understand it - try it and make a note:) starting with the basic script structure: starting with the basic script structure: #!/usr/bin/env python # """Module docstring.""" # Imports import time import sys # Module Constants CONSTANT_VARIABLE = "Variables that Probably shouldn't be changed" # Module "Global" Variables global_variable_file = "file....

December 31, 2019 · 4 min · Dmitry Golovach