Python Unit Test Automation: Automate, Organize, and Execute Unit Tests in Python Ashwin Pajankar pdf download
Python Unit Test Automation: Automate, Organize, and Execute Unit Tests in Python Ashwin Pajankar pdf download
https://ebookmeta.com/product/python-unit-test-automation-
automate-organize-and-execute-unit-tests-in-python-ashwin-
pajankar/
https://ebookmeta.com/product/python-unit-test-automation-
practical-techniques-for-python-developers-and-
testers-1-converted-edition-ashwin-pajankar/
https://ebookmeta.com/product/hands-on-matplotlib-learn-plotting-
and-visualizations-with-python-3-ashwin-pajankar/
https://ebookmeta.com/product/raspberry-pi-image-processing-
programming-develop-real-life-examples-with-python-pillow-and-
scipy-1st-edition-ashwin-pajankar/
https://ebookmeta.com/product/infernal-affairs-agents-of-
peace-1-1st-edition-destiny-draco/
Java: The Complete Reference (Complete Reference
Series) 13th Edition Schildt
https://ebookmeta.com/product/java-the-complete-reference-
complete-reference-series-13th-edition-schildt/
https://ebookmeta.com/product/not-so-innocent-bay-falls-
high-4-1st-edition-jaxson-kidman/
https://ebookmeta.com/product/love-love-victoria-chang/
https://ebookmeta.com/product/the-100-most-influential-
entertainers-of-stage-and-screen-1st-edition-virginia-forte-
jacob-steinberg/
https://ebookmeta.com/product/digital-business-models-
perspectives-on-monetisation-1st-edition-adam-jablonski/
Marked Wolf Tarot Daegon Academy 1 1st Edition Luna
Starling Lydia Vincent
https://ebookmeta.com/product/marked-wolf-tarot-daegon-
academy-1-1st-edition-luna-starling-lydia-vincent/
Python Unit
Test Automation
Automate, Organize, and
Execute Unit Tests in Python
—
Second Edition
—
Ashwin Pajankar
Python Unit Test
Automation
Automate, Organize, and
Execute Unit Tests in Python
Second Edition
Ashwin Pajankar
Python Unit Test Automation: Automate, Organize, and Execute
Unit Tests in Python
Ashwin Pajankar
Nashik, Maharashtra, India
v
Table of Contents
Powerful����������������������������������������������������������������������������������������������������������7
Community Support�����������������������������������������������������������������������������������������8
Python 3����������������������������������������������������������������������������������������������������������������8
Differences Between Python 2 and Python 3��������������������������������������������������8
Why Use Python 3������������������������������������������������������������������������������������������10
Installing Python 3����������������������������������������������������������������������������������������������11
Installation on Linux��������������������������������������������������������������������������������������11
Installation on Debian, Ubuntu, and Derivatives��������������������������������������������11
Installation on Fedora and CentOS����������������������������������������������������������������11
Installation on macOS X��������������������������������������������������������������������������������12
Installation on Windows��������������������������������������������������������������������������������12
Running a Python Program and Python Modes���������������������������������������������������15
Interactive Mode��������������������������������������������������������������������������������������������16
Script Mode���������������������������������������������������������������������������������������������������17
IDEs for Python����������������������������������������������������������������������������������������������������18
IDLE���������������������������������������������������������������������������������������������������������������18
The PyDev Plugin for Eclipse�������������������������������������������������������������������������19
Geany�������������������������������������������������������������������������������������������������������������20
PyCharm��������������������������������������������������������������������������������������������������������21
Conclusion����������������������������������������������������������������������������������������������������������23
vi
Table of Contents
Chapter 3: unittest������������������������������������������������������������������������������43
Introduction to xUnit��������������������������������������������������������������������������������������������44
Using unittest������������������������������������������������������������������������������������������������������45
Order of Execution of the Test Methods���������������������������������������������������������47
Test Discovery�����������������������������������������������������������������������������������������������������73
Coding Conventions for unittest��������������������������������������������������������������������������75
Assertions in unittest������������������������������������������������������������������������������������������76
Other Useful Methods������������������������������������������������������������������������������������78
Failing a Test�������������������������������������������������������������������������������������������������������79
Exceptions in Test Cases�������������������������������������������������������������������������������82
Creating Test Suites���������������������������������������������������������������������������������������86
Creating Test Suites���������������������������������������������������������������������������������������88
Conclusion����������������������������������������������������������������������������������������������������������89
vii
Table of Contents
Chapter 5: pytest������������������������������������������������������������������������������123
Introduction to pytest����������������������������������������������������������������������������������������124
Simple Test��������������������������������������������������������������������������������������������������124
Running Tests with the py.test Command���������������������������������������������������126
Test Class and Test Package in pytest���������������������������������������������������������127
Test Discovery in pytest�������������������������������������������������������������������������������129
xUnit-Style Fixtures�������������������������������������������������������������������������������������129
pytest Support for unittest and nose�����������������������������������������������������������131
Introduction to pytest Fixtures��������������������������������������������������������������������������131
Scope of pytest Fixtures������������������������������������������������������������������������������137
viii
Table of Contents
ix
Table of Contents
Customizing Tracing������������������������������������������������������������������������������������187
Customizing the Log Message Format and Display�������������������������������������189
Configuring with a Dictionary����������������������������������������������������������������������190
Conclusion��������������������������������������������������������������������������������������������������������191
Index�������������������������������������������������������������������������������������������������205
x
About the Author
Ashwin Pajankar is a programmer, a maker, an author, a YouTuber, and a
science popularizer. He graduated from IIIT Hyderabad with an MTech in
Computer Science and Engineering. He has a keen interest in promoting
science, technology, engineering, and mathematics (STEM) education.
He has written many books with Packt, Leanpub, BPB, and Apress, and
has also reviewed many books for Packt and Apress. He’s also working on
many more books with Apress.
His YouTube channel has more than 10,000 subscribers and he also
teaches more than 75,000 students on Udemy.
His personal website is www.AshwinPajankar.com.
His LinkedIn profile is
https://in.linkedin.com/in/ashwinpajankar
xi
About the Technical Reviewers
Shraddha Joshi is currently working as an engineer at PwC with experience
in testing with Python and Java in major production environments. She has
worked with various global clients across multiple domains and helped
them build products and solutions with full-fledged testing frameworks.
She has expertise in all phases of the development process and leads the
design, development, execution, and automation stages of test plans for
a diverse set of system components. Previously, she was a Senior Quality
Engineer at Incture Technologies, where she was involved in designing
functional integration and regression test plans, building and executing
manual and automated tests, and performing highly complex analysis for
multiple products. She also helped set cross-functional product testing
standards involving the application of advanced technical/business skills in
the area of specialization.
Shraddha’s great knack for simplifying concepts and explaining them
in an easy-to-understand manner makes her stand apart. She is passionate
about guiding and mentoring people in their technology journey. She is
also actively involved in conducting workshops, webinars, and sessions.
She lives in Bangalore with her family.
xiii
Acknowledgments
I am grateful to the student and teacher community which, with their
continual bombardment of queries, impelled me to learn more, simplify
my findings, and organize them into a book. This book is for them.
I wish to thank my friends and colleagues—the practitioners from the
field—for their good counsel and for filling me in on the latest in the field
of test automation.
A special thanks to the technical reviewers—Shraddha and Sujay—for
their vigilant review and for providing their expert opinions.
I consider myself very fortunate for the editorial assistance provided
by Apress; the collaboration with them has been fabulous. I am thankful
to Celestin Suresh John, Senior Manager, Editorial Acquisitions, Apress
and Springer Science and Business Media Company, for giving me
this and many other opportunities to collaborate with Apress. I wish to
acknowledge and appreciate James Markham, Mark Powers, and the
team of associates from Apress who adeptly guided me through the entire
process of preparation and publication.
xv
Introduction
Why This Book?
I have been using Python for more than ten years on a wide variety of
projects. Initially, I used it for GUI applications. Then I quickly moved to
scientific usage, as my academic projects demanded it. When I entered
professional life, I used it for automation first and then for implementation
of alert mechanisms. I have been using Python for the last six years in the
fields of scientific computing, Internet of Things (IoT), and single board
computers. I have written plenty of Python code over these years.
I always prefer it to bash scripting, which offers limited capabilities to
users like me. At different points over the last ten years, I’ve worked as a
developer, an R&D engineer, a maker, an author, and a QA specialist. I used
Python in every single role.
Whenever I write code, I unit test it thoroughly. I used to unit test all
my Python modules in the good old manual way. I used to run all the
scripts once and compare the outcome with what was expected. However,
I learned that when your codebase grows larger, it’s pretty difficult to test
the scripts manually. Also, all the scripts have to be tested, re-tested, and
tested for regression whenever a small part of the codebase changes. I was
looking for a way to run all the tests automatically, which led me to reading
about test automation. It immediately piqued my curiosity and, after a
couple of days, I was running my own automated Python tests.
After acquainting myself with the philosophy of test automation,
I applied my newfound knowledge to automate unit and integration testing
to web, mobile, GUI, API, and a variety of other types of applications using
programming languages like C++, Python, Java, and PHP.
xvii
Introduction
xviii
Other documents randomly have
different content
abundance; and the colonies and corporate towns will
open their gates to us. But if we lose the victory through
want of courage, those same places will turn against us,
for neither place nor friend will protect him whom his
arms have not protected. Besides, soldiers, the same
exigency does not press upon our adversaries as presses
upon us; we fight for our country, for our liberty, for our
life; they contend for what but little concerns them, the
power of a small party. Attack them, therefore, with so
much the greater confidence, and call to mind your
achievements of old.
We might, with the utmost ignominy, have passed the
rest of our days in exile. Some of you, after losing your
property, might have waited at Rome for assistance from
others. But because such a life, to men of spirit, was
disgusting and unendurable, you resolved upon your
present course. If you wish to quit it, you must exert all
your resolution, for none but conquerors have exchanged
war for peace. To hope for safety in flight when you have
turned away from the enemy the arms by which the body
is defended is indeed madness. In battle those who are
most afraid are always in most danger; but courage is
equivalent to a rampart.
When I contemplate you, soldiers, and when I consider
your past exploits, a strong hope of victory animates me.
Your spirit, your age, your valor, give me confidence; to
say nothing of necessity, which makes even cowards
brave. To prevent the numbers of the enemy from
surrounding us, our confined situation is sufficient. But
should Fortune be unjust to your valor, take care not to
lose your lives unavenged; take care not to be taken and
butchered like cattle, rather than, fighting like men, to
leave to your enemies a bloody and mournful victory.
cicero
Marcus Tullius Cicero, the greatest of the Roman orators, and one of
the foremost orators of all times, was born at Arpinum, on the
northern border of the Volscian territory, 106 b. c., and was killed by
order of Marc Antony at the close of the year 43 b. c. Thus passed away,
at the age of sixty-three, one of the most illustrious statesmen and the
most eloquent orator that the vast empire of Rome produced.
Cicero lived in a venal age, yet he escaped contamination. He was a
politician, yet he rarely stooped to the trickery of the ancient
politicians. Only in two instances did he fall below the high standard
of manliness up to which all must measure who would be esteemed
patriots: once, when he combined with Catiline, a notoriously corrupt
and ruined character, for the consulship; and again, in turning from
Pompey and crooking “the pregnant hinges of the knee” to Caesar
when that warrior’s star commenced to climb toward the zenith of his
fame. A weak trait in Cicero’s character was shown in his behavior
during banishment. Instead of bearing up bravely against the injustice
of his enemies, strong in the consciousness of his own rectitude, he
cringingly besought clemency and begged to be permitted to return to
Rome, thus tacitly admitting that there had been just grounds for his
banishment. Despite these failings, he was a truly great man who did
much for his country and the world. Much of his spoken and written
matter has come down to us and authentic information concerning his
education, his style of oratory, the manner of his life, and his views of
men and questions are to be had at first hand. He is not shrouded in
mystery, as are many great men of a much nearer period, but he can be
as clearly perceived by the student of today as he was by his
contemporaries—in fact, clearer, because the picture is not now, as it
was then, blurred by the excessive praise of friends nor the calumnies
of enemies.
All through his life Cicero worked to fit himself for adequately filling
such positions of honor and renown as he sought, and he finally
became the most perfect specimen of the Roman of the governing
class. As a youth he was under the instruction of the famous orator
Crassus, and he read the poets and orators of Greece under the
guidance of the Greek poet Archias, then a teacher at Rome, during the
early period of his schooling. He studied the Roman national law and
ritual under the two Scaevolas, as he desired a thorough knowledge of
these things in order that he might become a successful advocate. He
also studied under Philo, the chief of the Academics, Diodotus the
Stoic, and Milo the philosopher. He commenced his career as an
advocate when twenty-six years of age by a civil cause in the speech Pro
Quinctio, and in the following year he undertook a criminal cause in
the action brought against Roscius Amerinus. Soon after this he went
to Athens and diligently studied the art of declamation under the best
masters. Some claim that Cicero was not original in his matter nor his
manner; that he spent too much time studying the works and methods
of others; but be this as it may, he certainly became wonderfully
proficient in gathering the matter and presenting it in a manner that
was marvelously impressive and successful. He was undoubtedly the
best prepared orator that the world has ever known; and as a speaker
he was always master of himself, his subject, and his audience.
The First Oration Against Verres (70 b. c.). That which
was above all things to be desired, O judges, and which
above all things was calculated to have the greatest
influence toward allaying the unpopularity of your order,
and putting an end to the discredit into which your
judicial decisions have fallen, appears to have been
thrown in your way, and given to you not by any human
contrivance, but almost by the interposition of the gods,
at a most important crisis of the republic. For an opinion
has now become established, pernicious to us and
pernicious to the public, which has been the common
talk of every one, not only at Rome, but among foreign
nations also—that in the courts of law as they exist at
present, no wealthy man, however guilty he may be, can
possibly be convicted.
Now at this time of peril to your order and to your
tribunal, when men are ready to attempt by harangues,
and by the proposal of new laws, to increase the existing
unpopularity of the senate, Caius Verres is brought to
trial as a criminal—a man condemned in the opinion of
every one by his life and actions, but acquitted by the
enormousness of his wealth according to his own hope
and boast. I, O judges, have undertaken this cause as
prosecutor with the greatest good wishes and
expectation on the part of the Roman people, not in
order to increase the unpopularity of the senate, but to
relieve it from the discredit which I share with it. For I
have brought before you a man, by acting justly in whose
case you have an opportunity of retrieving the lost credit
of your judicial proceedings, of regaining your credit
with the Roman people, and of giving satisfaction to
foreign nations; a man, the embezzler of public funds,
the petty tyrant of Asia and Pamphylia, the robber who
deprived the city of its rights, the disgrace and ruin of
the province of Sicily. And if you come to a decision
about this man with severity and a due regard to your
oaths, that authority which ought to remain in you will
cling to you still; but if that man’s vast riches shall break
down the sanctity and honesty of the courts of justice, at
least I shall achieve this, that it shall be plain that it was
rather honest judgment that was wanting to the republic,
than a criminal to the judges or an accuser to the
criminal.
I, indeed, that I may confess to you the truth about
myself, O judges, though many snares were laid for me
by Caius Verres, both by land and sea, which I partly
avoided by my own vigilance, and partly warded off by
the zeal and kindness of my friends, yet I never seemed
to be incurring so much danger, and I never was in such
a state of great apprehension as I am now in this very
court of law. Nor does the expectation which people have
formed of my conduct of this prosecution, nor this
concourse of so vast a magnitude as is here assembled,
influence me (though indeed I am greatly agitated by
these circumstances) so much as his nefarious plots
which he is endeavoring to lay at one and the same time
against me, against you, against Marcus Glabrio, the
praetor, and against the allies, against foreign nations,
against the senate, and even against the very name of
senator; whose favorite saying it is that they have got to
fear who have stolen only as much as is enough for
themselves, but that he has stolen so much that it may
easily be plenty for many; that nothing is so holy that it
can not be corrupted, or so strongly fortified that it can
not be stormed by money. But if he were as secret in
acting as he is audacious in attempting; perhaps in some
particular he might some time or other have escaped our
notice.
But it happens very fortunately that to his incredible
audacity there is joined a most unexampled folly. For as
he was unconcealed in committing his robberies of
money, so in his hope of corrupting the judges he has
made his intentions and endeavors visible to every one.
He says that only once in his life has he felt fear at the
time when he was first impeached as a criminal by me;
because he was only lately arrived from his province, and
was branded with unpopularity and infamy, not modern
but ancient and of long standing; and, besides that, the
time was unlucky, being very ill suited for corrupting the
judges. Therefore, when I had demanded a very short
time to prosecute my inquiries in Sicily, he found a man
to ask for two days less to make investigations in Achaia;
not with any real intention of doing the same with his
diligence and industry, that I have accomplished by my
labor, and daily and nightly investigations. For the
Achaean inquisitor never even arrived at Brundusium. I
in fifty days so traveled over the whole of Sicily that I
examined into the records and injuries of all the tribes
and of all private individuals, so that it was easily visible
to every one that he had been seeking out a man not
really for the purpose of bringing the defendant whom
he accused to trial, but merely to occupy the time which
ought to belong to me.
Now that most audacious and most senseless man thinks
this. He is aware that I am come into court so thoroughly
prepared and armed that I shall fix all his thefts and
crimes not only in your ears, but in the very eyes of all
men. He sees that many senators are witnesses of his
audacity; he sees that many Roman knights are so, too,
and many citizens, and many of the allies besides to
whom he has done unmistakable injuries. He sees also
that very numerous and very important deputations have
come here at the same time from friendly cities, armed
with the public authority and evidence collected by their
states.
In truth, what genius is there so powerful, what faculty of
speaking, what eloquence so mighty, as to be in any
particular able to defend the life of that man convicted as
it is of so many vices and crimes, and long since
condemned by the inclinations and private sentiments of
every one. And, to say nothing of the stains and disgraces
of his youth, what other remarkable event is there in his
questorship, that first step to honor, except that Cnaeus
Carbo was robbed by his questor of the public money?
that the consul was plundered and betrayed? his army
deserted? his province abandoned? the holy nature and
obligations imposed on him by lot violated? whose
lieutenancy was the ruin of all Asia and Pamphylia, in
which provinces he plundered many houses, very many
cities, all the shrines and temples; when he renewed and
repeated against Cnaeus Dolabella his ancient wicked
tricks when he had been questor, and did not only in his
danger desert, but even attack and betray the man to
whom he had been lieutenant, and proquaestor, and
whom he had brought into odium by his crimes; whose
city praetorship was the destruction of the sacred
temples and the public works, and, as to his legal
decisions, was the adjudging and awarding of property
contrary to all established rules and precedents. But now
he has established great and numerous monuments and
proofs of all his vices in the province of Sicily, which he
for three years so harassed and ruined that it can by no
possibility be restored to its former condition, and
appears scarcely able to be at all recovered after a long
series of years, and a long succession of virtuous
praetors. While this man was praetor the Sicilians
enjoyed neither their own laws nor the decrees of our
senate, nor the common rights of every nation. Every one
in Sicily has only so much left as either escaped the
notice or was disregarded by the satiety of that most
avaricious and licentious man.
No legal decision for three years was given on any other
ground but his will; no property was so secure to any
man, even if it had descended to him from his father and
grandfather, but he was deprived of it at his command;
enormous sums of money were exacted from the
property of the cultivators of the soil by a new and
nefarious system. The most faithful of the allies were
classed in the number of enemies. Roman citizens were
tortured and put to death like slaves; the greatest
criminals were acquitted in the courts of justice through
bribery; the most upright and honorable men, being
prosecuted while absent, were condemned and banished
without being heard in their own defense; the most
fortified harbors, the greatest and strongest cities, were
laid open to pirates and robbers; the sailors and soldiers
of the Sicilians, our own allies and friends, died of
hunger; the best built fleets on the most important
stations were lost and destroyed, to the great disgrace of
the Roman people. This same man while praetor
plundered and stripped those most ancient monuments,
some erected by wealthy monarchs and intended by
them as ornaments for their cities; some, too, the work of
our own generals, which they either gave or restored as
conquerors to the different states in Sicily. And he did
this not only in the case of public statues and ornaments,
but he also plundered all the temples consecrated in the
deepest religious feelings of the people. He did not leave,
in short, one god to the Sicilians which appeared to him
to be made in a tolerable workmanlike manner, and with
any of the skill of the ancients.
I am prevented by actual shame from speaking of his
nefarious licentiousness as shown in rapes and other
such enormities; and I am unwilling also to increase the
distress of those men who have been unable to preserve
their children and their wives unpolluted by his wanton
lust. But, you will say, these things were done by him in
such a manner as not to be notorious to all men. I think
there is no man who has heard his name who cannot also
relate wicked actions of his; so that I ought rather to be
afraid of being thought to omit many of his crimes, than
to invent any charges against him. And, indeed, I do not
think that this multitude which has collected to listen to
me wishes so much to learn of me what the facts of the
case are, as to go over it with me, refreshing its
recollection of what it knows already.
And as this is the case, that senseless and profligate man
attempts to combat me in another manner. He does not
seek to oppose the eloquence of any one else to me; he
does not rely on the popularity, or influence, or authority,
of any one. He pretends that he trusts to those things;
but I see what he is really aiming at (and indeed he is not
acting with any concealment). He sets before me empty
titles of nobility—that is to say, the names of arrogant
men, who do not hinder me so much by being noble, as
assist me by being notorious; he pretends to rely on their
protection, when he has in reality been contriving
something else this long time. What hope he now has,
and what he is endeavoring to do, I will now briefly
explain to you, O judges.
But first of all, remark, I beg you, how the matter has
been arranged by him from the beginning. When he first
returned from the province he endeavored to get rid of
his prosecution by corrupting the judges at a great
expense; and this object he continued to keep in view till
the conclusion of the appointment of the judges. After
the judges were appointed, because in drawing lots for
them the fortune of the Roman people had defeated his
hopes, and in the rejecting some my diligence had
defeated his impudence, the whole attempt at bribery
was abandoned. The affair was now going on admirably;
lists of your names and of the whole tribunal were in
every one’s hands. It did not seem possible to mark the
votes of these men with any distinguishing mark or color
or spot of dirt; and that fellow, from having been brisk
and in high spirits, became on a sudden so downcast and
humbled that he seemed to be condemned not only by
the Roman people but even by himself. But lo! all of a
sudden, within these few days, since the consular comitia
have taken place, he has gone back to his original plan
with more money, and the same plots are now laid
against your reputation and against the fortunes of every
one, by the instrumentality of the same people; which
fact at first, O judges, was pointed out by me by a very
slight hint and indication; but afterward, when my
suspicions were once aroused, I arrived at the knowledge
of all the most secret counsels of that party without any
mistake.
For as Hortensius, the consul-elect, was being attended
home again from the Campus by a great concourse and
multitude of people, Caius Curio fell in with that
multitude by chance—a man whom I wish to name by
way of honor rather than disparagement. I will tell you
what if he had been unwilling to have it mentioned, he
would not have spoken of in so large an assembly so
openly and undisguisedly; which, however, shall be
mentioned by me deliberately and cautiously, that it may
be seen that I pay due regard to our friendship and to his
dignity. He sees Verres in the crowd by the arch of
Fabius,[3] he speaks to the man, and with a loud voice
congratulates him on his victory. He does not say a word
to Hortensius himself, who had been made consul, or to
his friends and relations who were present attending on
him; but he stops to speak to this man, embraces him,
and bids him cast off all anxiety. “I give you notice,” said
he, “that you have been acquitted by this day’s comitia.”
And as many most honorable men heard this, it is
immediately reported to me the first thing. To some it
appeared scandalous, to others, again, ridiculous—
ridiculous to those who thought that this case depended
on the credibility of the witnesses, on the importance of
the charges, and on the power of the judges, and not on
the consular comitia; scandalous to those who looked
deeper, and who thought and this congratulation had
reference to the corruption of the judges.
In truth, they argued in this manner—the most
honorable men spoke to one another and to me in this
manner—that there were now manifestly and
undeniably no courts of justice at all. The very criminal
who the day before thought that he was already
condemned, is acquitted, now that his defender has been
made consul. What are we to think then? Will it avail
nothing at all Sicily, all the Sicilians, that all the
merchants who have business in that country, that if the
consul-elect wills it otherwise. What! will not the judges
be influenced by the accusation, by the evidence, by the
universal opinion of the Roman people? No. Everything
will be governed by the power and authority of one man.
In the meantime my comitia began to be held; of which
that fellow thought himself the master, as he had been of
all the other comitia this year. He began to run about,
that influential man, with his son, a youth of engaging
and popular manners, among the tribes. The son began
to address and to call on all the friends of his father—
that is to say, all his agents—for bribery; and when this
was noticed and perceived, the Roman people took care
with the most earnest good will that I should not be
deprived of my honor through the money of that man,
whose riches had not been able to make me violate my
good faith. After that I was released from the great
anxiety about my canvass, I began, with a mind much
more unoccupied and much more at ease, to think of
nothing and to do nothing except what related to this
trial. I find, O judges, these plans formed and begun to
be put in execution by them to protract the matter,
whatever steps it might be necessary to take in order to
do so, so that the cause might be pleaded before Marcus
Metellus as praetor. That by doing so they would have
these advantages: firstly, that Marcus Metellus was most
friendly to them; secondly, that not only would
Hortensius be consul, but Quintus Metellus also; and
listen while I show you how a great a friend he is to them.
For he gave him a token of his good will of such a sort
that he seemed to be giving it as a return for the suffrages
of the tribes which he had secured to him. Did you think
that I would say nothing of such serious matters as
these? and that, at a crisis of such danger to the republic
and my own character, I would consult anything rather
than my duty and my dignity? The other consul-elect
sent for the Sicilians; some came, because Lucius
Metellus was praetor in Sicily. To them he speaks in this
manner: that he is the consul; that one of his brothers
has Sicily for a province; that the other is to be judge in
all prosecutions for extortion; and that care had been
taken in many ways that there should be no possibility of
Verres being injured.
I ask you, Metellus, what is corrupting the course of
justice, if this is not—to seek to frighten witnesses, and
especially Sicilians, timid and oppressed men, not only
by your own private influence, but by their fear of the
consul, and by the power of two praetors? What could
you do for an innocent man or for a relation, when for
the sake of a most guilty one, entirely unconnected with
you, you depart from your duty and your dignity, and
allow what he is constantly saying to appear true to any
one who is not acquainted with you? For they said that
Verres said that you had not been made consul by
destiny, as the rest of your family had been, but by his
assistance. Two consuls, therefore, and the judge are to
be such because of his will. We shall not only, says he,
avoid having a man too scrupulous in investigating, too
subservient to the opinion of the people, Marcus Glabrio,
but we shall have this advantage also: Marcus Caesonius
is the judge, the colleague of your accuser, a man of tried
and proved experience in the decision of actions. It will
never do for us to have such a man as that on the bench,
which we are endeavoring to corrupt by some means or
other; for before, when he was one of the judges on the
tribunal of which Junius was president, he was not only
very indignant at the shameful transaction, but he even
betrayed and denounced it.
But as for what I had begun to say—namely, that the
contest is between you and me, this is it—I, when I had
undertaken this cause at the request of the Sicilians, and
had thought it a very honorable and glorious thing for
me that they were willing to make experiment of my
integrity and diligence, who already knew by experience
my innocence and temperance: then, when I had
undertaken this business, I proposed to myself some
greater action also by which the Roman people should be
able to see my good will toward the republic. For that
seemed to me to be by no means worthy of my industry
and efforts, for that man to be brought to trial by me who
had already condemned by the judgment of all men,
unless that intolerable influence of yours, and that
grasping nature which you have displayed for some years
in many trials, were interposed also in the case of that
desperate man. But now, since all this dominion and
sovereignty of yours over the courts of justice delights
you so much, and since there are some men who are
neither ashamed of their licentiousness and their infamy,
nor weary of it, and who, as if on purpose, seem to wish
to encounter hatred and unpopularity from the Roman
people, I profess that I have undertaken this, a great
burden perhaps, and one dangerous to myself, but still
worthy of my applying myself to it with all the vigor of
my age, and all diligence.
And since the whole order of the senate is weighed down
by the discredit brought on it by the wickedness and
audacity of a few, and is overwhelmed by the infamy of
the tribunals, I profess myself an enemy to this race of
men, an accuser worthy of their hatred, a persevering, a
bitter adversary. I arrogate this to myself, I claim this for
myself, and I will carry out this enmity in my magistracy,
and from that post in which the Roman people have
willed that from the next first of January I shall act in
concert with it in matters concerning the republic, and
concerning wicked men. I promise the Roman people
that this shall be the most honorable and the fairest
employment of my aedileship. I warn, I forewarn, I give
notice beforehand to those men who are wont either to
put money down, to undertake for others, to receive
money, or to promise money, or to act as agents in
bribery, or as go-betweens in corrupting the seat of
judgment, and who have promised their influence or
their impudence in aid of such a business, in this trial to
keep their hands and inclination from this nefarious
wickedness.
And what do you suppose will be my thoughts, if I find in
this very trial any violation of the laws committed in any
similar manner? especially when I can prove by many
witnesses that Caius Verres often said in Sicily, in the
hearing of many persons, “that he had a powerful friend,
in confidence with whom he was plundering the
province; and that he had so distributed the three years
of his Sicilian praetorship that should say he did
exceedingly well, if he appropriated the gains of one year
to the augmentation of his own property, those of the
second year to his patrons and defenders, and reserved
the whole of the third year, the most productive and
gainful of all, for the judges.”
From which it came into my mind to say that which,
when I had said lately before Marcus Glabrio at the time
of striking the list of judges, I perceived the Roman
people greatly moved by: that I thought that foreign
nations would send ambassadors to the Roman people to
procure the abrogation of the law, and of all trials, about
extortion; for if there were no trials, they think that each
man would only plunder them of as much as he would
think sufficient for himself and his children; but now,
because there are trials of that sort, every one carries off
as much as it will take to satisfy himself, his patrons, his
advocates, the praetor, and the judges; and that this is an
enormous sum; that they may be able to satisfy the
cupidity of one most avaricious man, but are quite
unable to incur the expense of his most guilty victory
over the laws. O trials worthy of being recorded! O
splendid reputation of our order! when the allies of the
Roman people are unwilling that trials for extortion
should take place, which were instituted by our ancestors
for the sake of all allies. Would that man ever have had a
favorable hope of his own safety, if he had not conceived
in his mind a bad opinion of you? on which account, he
ought, if possible, to be still more hated by you than he is
by the Roman people, because he considers you like
himself in avarice and wickedness and perjury.
And I beg you, in the name of the immortal gods, O
judges, think of and guard against this; I warn you, I give
notice to you of what I am well assured, that this most
seasonable opportunity has been given to you by the
favor of the gods, for the purpose of delivering your
whole order from hatred, from unpopularity, from
infamy, and from disgrace. There is no severity believed
to exist in the tribunals, nor any scruples with regard to
religion; in short, there are not believed to be any
tribunals at all. Therefore we are despised and scorned by
the Roman people; we are branded with a heavy and now
long standing infamy. Nor, in fact, is there any other
reason for which the Roman people has with so much
earnestness sought the restoration of the tribunician
power: but when it was demanding that in words, it
seemed to be asking for that, but in reality it was asking
for tribunals which it could trust.
But now men on the watch-towers; they observe how
every one of you behaves himself in respecting religion
and observing the laws. They see that, ever since the
passing of the law for restoring the power of the tribunes,
only one senator, and he, too, a very insignificant one,
has been condemned. And though they do not blame
this, yet they have nothing which they can very much
command. For there is no credit in being upright in a
case where there is no one who is either able or who
endeavors to corrupt one. This is a trial in which you will
be deciding about the defendant, the Roman people
about you; by the example of what happens to this man it
will be determined whether, when senators are the
judges, a very guilty and a very rich man can be
condemned.
On which account, in the first place, I beg this of the
immortal gods, which I seem to myself to have hopes of,
too—that in this trial no one may be found to be wicked
except he who has long since been found to be such;
secondly, if there are many wicked men, I promise this to
you, O judges, I promise this to the Roman people, that
my life shall fail rather than my vigor and perseverance in
prosecuting their iniquity. But that iniquity, which if it
should be committed, I promise to prosecute severely,
with however much trouble and danger to myself, and
whatever enmities I may bring on myself by doing so,
you, O Marcus Glabrio, can guard against ever taking
place by your wisdom, and authority, and diligence. Do
you undertake the cause of the tribunals? Do you
undertake the cause of impartiality, of integrity, of good
faith and religion? Do you undertake the cause of the
senate, that, being proved worthy by its conduct in this
trial, it may come into favor and popularity with the
Roman people? Think who you are and in what a
situation you are placed; what you ought to give to the
Roman people and what you ought to repay to your
ancestors. Let the recollection of the Acilian Law passed
by your father occur to your mind, owing to which law
the Roman people has had this advantage of most
admirable decisions and very strict judges in cases of
extortion.
I am resolved not to permit the praetor or the judges to
be changed in this cause. I will not permit the matter to
be delayed till the lictors of the consuls can go and
summon the Sicilians, whom the servants of the consuls-
elect did not influence before, when by an
unprecedented course of proceeding they sent for them
all; I will not permit these miserable men, formerly the
allies and friends of the Roman people, now their slaves
and supplicants, to lose not only their rights and
fortunes by their tyranny, but to be deprived of even the
power of bewailing their condition; I will not, I say, when
the cause has been summed up by me, permit them after
a delay of forty days has intervened, then at last to reply
to me when my accusation has already fallen into
oblivion through lapse of time; I will not permit the
decision to be given when this crowd collected from all
Italy has departed from Rome, which has assembled
from all quarters at the same time on account of the
comitia, of the games, and of the census.
The reward of the credit gained by your decision, or the
danger arising from the unpopularity which will accrue
to you if you decide unjustly, I think ought to belong to
you; the labor and anxiety to me; the knowledge of what
is done and the recollection of what has been said by
every one, to all. I will adopt this course, not an
unprecedented one, but one that has been adopted
before, by this who are now the chief men of our state—
the course, I mean, of at once producing the witnesses.
What you will find novel, O judges, is this, that I will so
marshal my witnesses as to unfold the whole of my
accusation; that when I have established it by examining
my witnesses, by arguments, and by my speech, then I
shall show the agreement of the evidence with my
accusation: so that there shall be no difference between
the established mode of prosecuting, and this new one,
except that, according to the established mode, when
everything has been said which is to be said, then the
witnesses are produced; here they shall be produced as
each count is brought forward, so that the other side
shall have the same opportunity of examining them, of
arguing and making speeches on their evidence. If there
be any one who prefers an uninterrupted speech and the
old mode of conducting a prosecution without any
break, he shall have it in some other trial. But for this
time let him understand that what we do is done by us
on compulsion (for we only do it with the design of
opposing the artifice of the opposite party by our
prudence). This will be the first part of the prosecution.
We say that Caius Verres has not only done many
licentious acts, many cruel ones, toward Roman citizens,
and toward some of the allies, many wicked acts against
both gods and man; but especially that he has taken
away four hundred thousand sesterces out of Sicily
contrary to the laws. We will make this so plain to you by
witnesses, by private documents, and by public records,
that you shall decide that, even if we had abundant space
and leisure days for making a long speech without any
inconvenience, still there was no need at all of a long
speech in this matter.
FOOTNOTES:
CHAPTER IX
DANIEL WEBSTER
On the Clay Compromise[2]
(Known as “The Seventh of March Speech,” 1850)
Slavery did exist in the states before the adoption of this
Constitution, and at that time. Let us, therefore, consider
for a moment what was the state of sentiment, North and
South, in regard to slavery—in regard to slavery at the
time this Constitution was adopted. A remarkable
change has taken place since; but what did the wise and
great men of all parts of the country think of slavery
then? In what estimation did they hold it at the time
when this Constitution was adopted? It will be found, sir,
if we will carry ourselves by historical research back to
that day, and ascertain men’s opinions by authentic
records still existing among us, that there was no
diversity of opinion between the North and the South
upon the subject of slavery. It will be found that both
parts of the country held it equally an evil, a moral and
political evil. It will not be found that, either at the North
or at the South, there was much, though there was some,
invective against slavery as inhuman and cruel.
The great ground of objection to it was political; that it
weakened the social fabric; that, taking the place of free
labor, society became less strong and labor less
productive; and therefore we find from all the eminent
men of the time and clearest expression of their opinion
that slavery is an evil. They ascribed its existence here,
not without truth, and not without some acerbity of
temper and force of language, to the injurious policy of
the mother country, who, to favor the navigator, had
entailed these evils upon the Colonies.
The whole interest of the South became connected, more
or less, with the extension of slavery. If we look back to
the history of the commerce of this country in the early
years of this government, what were our exports? Cotton
was hardly, or but to a very limited extent, known. In
1791 the first parcel of cotton of the growth of the
United States was exported, and amounted only to
19,200 pounds. It has gone on increasing rapidly, until
the whole crop may now, perhaps, in a season of great
product and high prices, amount to a hundred millions
of dollars. In the years I have mentioned, there was more
of wax, more of indigo, more of rice, more of almost
every article of export from the South, than of cotton.
When Mr. Jay negotiated the treaty of 1794 with
England, it is evident from the Twelfth Article of the
Treaty, which was suspended by the Senate, that he did
not know that cotton was exported at all from the United
States.
Mr. President, in the excited times in which we live, there
is found to exist a state of crimination and recrimination
between the North and the South. There are lists of
grievances produced by each; and these grievances, real
or supposed, alienate the minds of one portion of the
country from the other, exasperate the feelings, and
subdue the sense of fraternal affection, patriotic love,
and mutual regard. I shall bestow a little attention, sir,
upon those various grievances existing on the one side
and on the other. I begin with complaints of the South. I
will not answer, further than I have, the general
statements of the honorable senator from South
Carolina, that the North has prospered at the expense of
the South in consequence of the manner of
administering the government, in the collection of its
revenues, and so forth. These are disputed topics, and I
have no inclination to enter into them.
But I will allude to other complaints of the South, and
especially to one which has, in my opinion, just
foundation, and that is, that there has been found at the
North, among individuals and among legislators, a
disinclination to perform fully their constitutional duties
in regard to the return of persons bound to service who
have escaped into the free States. In that respect, the
South, in my judgment, is right, and the North is wrong.
Every member of every Northern Legislature is bound by
oath, like every other officer in the country, to support
the Constitution of the United States; and the article of
the Constitution which says to these states that they shall
deliver up fugitives from service, is as binding in honor
and conscience as any other article. No man fulfils his
duty in any legislature who sets himself to find excuses,
evasions, escapes from this constitutional obligation. I
have always thought that the Constitution addressed
itself to the legislatures of the states or the states
themselves. It says that those persons escaping to other
states “shall be delivered up,” and I confess I have always
been of the opinion that it was an injunction upon the
states themselves. When it is said that a person escaping
into another state, and coming therefore within the
jurisdiction of that state, shall be delivered up, it seems
to me the import of the clause is, that the state itself, in
obedience to the Constitution, shall cause him to be
delivered up. That is my judgment. I have always
entertained that opinion, and I entertain it now.
Then, sir, there are abolition societies, of which I am
unwilling to speak, but in regard to which I have very
clear notions and opinions. I do not think them useful. I
think their operations for the last twenty years have
produced nothing good or valuable. At the same time, I
believe thousands of their members to be honest and
good men, perfectly well-meaning men. They have
excited feelings; they think they must do something for
the cause of liberty; and, in their sphere of action, they
do not see what else they can do than to contribute to an
abolition press, or an abolition society, or to pay an
abolition lecturer.
I do not mean to impute gross motives even to the
leaders of these societies, but I am not blind to the
consequences of their proceedings. I can not but see
what mischief their interference with the South has
produced. And is it not plain to every man? Let any
gentleman who entertains doubts on this point, recur to
the debates in the Virginia House of Delegates in 1832,
and he will see with what freedom a proposition made by
Mr. Jefferson Randolph, for the gradual abolition of
slavery was discussed in that body. Every one spoke of
slavery, as he thought; very ignominious and disparaging
names and epithets were applied to it. The debates in the
House of Delegates on that occasion, I believe were all
published. They were read by every colored man who
could read, and to those who could not read, those
debates were read by others. At that time Virginia was
not unwilling or afraid to discuss this question, and to let
that part of her population know as much of the
discussion as they could learn.
That was in 1832. As has been said by the honorable
member from South Carolina, these abolition societies
commenced their course of action in 1835. It is said, I do
not know how true it may be, that they sent incendiary
publications into the slave states; at any rate, they
attempted to arouse, and did arouse, a very strong
feeling; in other words, they created great agitation in
the North against southern slavery. Well, what was the
result? The bonds of the slaves were bound more firmly
than before; their rivets were more strongly fastened.
Public opinion, which in Virginia had begun to be
exhibited against slavery, and was opening out for the
discussion of the question, drew back and shut itself up
in its castle. I wish to know whether anybody in Virginia
can now talk openly, as Mr. Randolph, Governor
McDowell, and others talked in 1832, and sent their
remarks to the press. We all know the fact, and we all
know the cause; and everything that these agitating
people have done has been, not to enlarge, but to
restrain, not to act free, but to bind faster, the slave
population of the South.
Mr. President, I should much prefer to have heard from
every member on this floor declarations of opinion that
this Union could never be dissolved, than the declaration
of opinion by anybody, that in any case, under the
pressure of any circumstances, such a dissolution was
possible. I hear with distress and anguish the word
“secession” especially when it falls from the lips of those
who are patriotic, and known to the country, and known
all over the world for their political services. Secession!
peaceable secession! Sir, your eyes and mine are never
destined to see that miracle. The dismemberment of this
vast country without convulsion! The breaking up of the
foundations of the great deep without ruffling the
surface! Who is so foolish—I beg everybody’s pardon—as
to expect to see any such thing?
Sir, he who sees these states now revolving in harmony
around a common center, and expects to see them quit
their places and fly off without convulsion, may look the
next hour to see the heavenly bodies rush from their
spheres, and jostle against each other in the realms of
space, without causing the crush of the universe. There
can be no such thing as a peaceable secession. Peaceable
secession is an utter impossibility. Is the great
Constitution under which we live, covering this whole
country, is it to be thawed and melted away by secession,
as the snows on the mountains melt under the influence
of a vernal sun, disappear almost unobserved, and run
off? No, sir! No, sir! I will not state what might produce
the disruption of the Union; but sir, I see, as plainly as I
see the sun in heaven, what the disruption itself must
produce; I see that it must produce war, and such a war
as I will not describe, in its twofold character.
Peaceable secession! peaceable secession! The
concurrent agreement of all the members of this great
Republic to separate! A voluntary separation, with
alimony on one side and on the other. Why, what would
be the result? Where is the line to be drawn? What states
are to secede? What is to remain American? What am I
to be? An American no longer? Am I to become a
sectional man, a local man, a separatist, with no country
in common with the gentlemen who sit around me here,
or who fill the other House of Congress? Heaven forbid!
Where is the flag of the Republic to remain? Where is
the eagle still to tower?—or is he to cower, and shrink,
and fall to the ground?
Why, sir, our ancestors—our fathers and our
grandfathers, those of them that are yet living among us,
with prolonged lives—would rebuke and reproach us;
and our children and our grandchildren would cry out
shame upon us, if we, of this generation, would dishonor
these ensigns of the power of the government and the
harmony of that Union, which is every day felt among us
with so much joy and gratitude. What is to become of
the army? What is to become of the navy? What is to
become of the public lands? How is any one of the thirty
states to defend itself?
Sir, we could not sit down here today, and draw a line of
separation that would satisfy any five men in the country.
There are natural causes that would keep and tie us
together; and there are social and domestic relations
which we could not break if we would, and which we
should not if we could.
Sir, nobody can look over the face of this country, at the
present moment, nobody can see where its population is
the most dense and growing, without being ready to
admit, and compelled to admit, that ere long the
strength of America will be in the valley of the
Mississippi. Well, now, sir, I beg to inquire what the
wildest enthusiast has to say on the possibility of cutting
that river in two, and leaving free states at its source and
on its branches, and slave states down near its mouth,
each forming a separate government? Pray, sir, let me say
to the people of this country, that these things are worthy
of their pondering and of their consideration. Here, sir,
are five millions of freemen in the free states north of the
river Ohio.
Can anybody suppose that this population can be
severed, by a line that divides them from the territory of
a foreign and alien government, down somewhere, the
Lord knows where, upon the lower banks of the
Mississippi? What would become of Missouri? Will she
join the arrondissement of the slave states? Shall the man
from the Yellowstone and the Platte be connected, in the
new Republic, with the man who lives on the southern
extremity of the Cape of Florida? Sir, I am ashamed to
pursue this line of remark. I dislike it; I have an utter
disgust for it. I would rather hear of natural blasts and
mildews, war, pestilence, and famine, than to hear
gentlemen talk of secession. To break up this great
government! to dismember this glorious country! to
astonish Europe with an act of folly such as Europe for
two centuries has never beheld in any government or any
people! No, sir! no, sir! There will be no secession!
Gentlemen are not serious when they talk of secession.