← Back
Editing: test_monkey.cpython-38.pyc
U W[ � @ sP d Z ddlmZmZ ddlmZ ddlmZ G dd� d�ZG dd� dej �Z d S ) z% Tests for L{twisted.python.monkey}. � )�division�absolute_import)�unittest)� MonkeyPatcherc @ s e Zd Zdd� ZdS )�TestObjc C s d| _ d| _d| _d S )Nz foo valuez bar valuez baz value)�foo�bar�baz��self� r �:/usr/lib/python3/dist-packages/twisted/test/test_monkey.py�__init__ s zTestObj.__init__N)�__name__� __module__�__qualname__r r r r r r s r c @ sh e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z dd� Zdd� Zdd� Z dd� ZdS )�MonkeyPatcherTestsz; Tests for L{MonkeyPatcher} monkey-patching class. c C s t � | _t � | _t� | _d S �N)r � testObject�originalObjectr � monkeyPatcherr r r r �setUp s zMonkeyPatcherTests.setUpc C sJ | j �� | �| jj| jj� | �| jj| jj� | �| jj| jj� dS )zL A monkey patcher without patches shouldn't change a thing. N)r �patch�assertEqualr r r r r r r r r � test_empty! s zMonkeyPatcherTests.test_emptyc C sZ t | jddf| jddf�}|�� | �d| jj� | �d| jj� | �| jj| jj� dS )z} Constructing a L{MonkeyPatcher} with patches should add all of the given patches to the patch list. r �hahar ZheheN)r r r r r r r r )r Zpatcherr r r �test_constructWithPatches. s �z,MonkeyPatcherTests.test_constructWithPatchesc C s0 | j �| jdd� | j �� | �| jjd� dS )zf Patching an attribute that exists sets it to the value defined in the patch. r r N)r �addPatchr r r r r r r r �test_patchExisting; s z%MonkeyPatcherTests.test_patchExistingc C s&