Python Unit Test Automation


CHAPTER 4 nose and nose2



Download 1,71 Mb.
Pdf ko'rish
bet41/73
Sana31.12.2021
Hajmi1,71 Mb.
#213720
1   ...   37   38   39   40   41   42   43   44   ...   73
Bog'liq
2 5188215245394412341

CHAPTER 4
nose and nose2
The last chapter introduced xUnit and unittest. In this chapter, we will explore yet 
another unit testing API for Python, called nose. The tagline of nose is, nose extends 
unittest to make testing easier.
You can use nose’s API to write and run automated tests. You can also use nose to 
run tests written in other frameworks like unittest. This chapter will also explore the 
next actively developed and maintained iteration of nose, nose2.
Introduction to nose
nose is not the part of Python’s standard library. You have to install it in order to use it. 
Let’s see how we can install it on Python 3.
Installing nose on Linux OS
The easiest way to install nose on a Linux computer is to install it using Python’s package 
manager pip. Pip stands for pip installs packages. It’s a recursive acronym. If pip is not 
installed on your Linux computer, you can install it by using a system package manager. 
On any Debian/Ubuntu or derivative computer, install pip with the following command:
sudo apt-get install python3-pip
On Fedora/CentOS and derivatives, run following commands (assuming you have 
Python 3.5 installed on the OS) to install pip:
sudo yum install python35-setuptools
sudo easy_install pip
Once pip is installed, you can install nose with the following command:
sudo pip3 install nose


Chapter 4 

 nose and nose2
66
Installing nose on MacOS and Windows
pip is pre-installed with Python 3 on MacOS and Windows. Install nose with the following 
command:
pip3 install nose
Verifying the Installation
Once nose is installed, run the following command to verify the installation:
nosetests -V
It will show output as follows:
nosetests version 1.3.7
Getting Started with nose
To get started with nose, follow the same path of exploration that you followed with 
unittest. Create a directory called chapter04 in the code directory and copy the 
mypackage directory from the chapter03 directory to code. You will need it later. Create a 
directory called test too. After all this, the chapter04 directory structure should look like 
the structure shown in Figure 
4-1
.
Save all the code examples to the test directory only.
A Simple nose Test Case
A very simple nose test case is demonstrated in Listing 
4-1
.

Download 1,71 Mb.

Do'stlaringiz bilan baham:
1   ...   37   38   39   40   41   42   43   44   ...   73




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish