#!/usr/bin/env python3 """ Task1: tests (support for python, numpy and matplotlib) """ import platform def os_info(): """ Collects basic info on the operating system and logs it to a file 'os_info.txt'. """ os_type = platform.system() os_rel = platform.release() os_ver = platform.version() return f"os: {os_type} {os_rel} {os_ver}\n" def python_info(): """ Obtains information on Python installation in use and logs it to a file 'python_info.txt'. """ python_ver = platform.python_version() python_impl = platform.python_implementation() return f"py: {python_impl} {python_ver}\n" import numpy def numpy_info(): """ Obtains information on the numpy package in use and logs it to a file 'numpy_info.txt'. """ numpy_name = numpy.__name__ numpy_ver = numpy.__version__ return f"np: {numpy_name} {numpy_ver}\n" import matplotlib def matplotlib_info(): """ Obtains information on the matplotlib package in use and logs it to a file 'matplotlib_info.txt'. """ matplotlib_name = matplotlib.__name__ matplotlib_ver = matplotlib.__version__ return f"mpl: {matplotlib_name} {matplotlib_ver}\n" import unittest import os class Test(unittest.TestCase): def test_python_env(self): with open("info_python.txt", "w") as f: f.write(os_info()) f.write(python_info()) f.write(numpy_info()) f.write(matplotlib_info()) if __name__ == '__main__': unittest.main()