← Back
Editing: test_fakepwd.cpython-38.pyc
U W[7 � @ s� d Z zddlZW n ek r( dZY nX zddlZW n ek rN dZY nX ddlZddlmZ ddlmZ ddl m Z mZ dZdd� Z e � ZG d d � d e�ZG dd� dee�ZG d d� dee�ZG dd� de�ZG dd� dee�ZG dd� dee�ZdS )z& Tests for L{twisted.python.fakepwd}. � N)�getitem)�TestCase)�UserDatabase�ShadowDatabasei� c C sB t } tdk r>zt�| � W n tk r2 Y q>Y qX | d8 } q| S )a� By convention, UIDs less than 1000 are reserved for the system. A system which allocated every single one of those UIDs would likely have practical problems with allocating new ones, so let's assume that we'll be able to find one. (If we don't, this will wrap around to negative values and I{eventually} find something.) @return: a user ID which does not exist on the local system. Or, on systems without a L{pwd} module, return C{SYSTEM_UID_MAX}. N� )�SYSTEM_UID_MAX�pwd�getpwuid�KeyError)Zguess� r �B/usr/lib/python3/dist-packages/twisted/python/test/test_fakepwd.py�findInvalidUID s r c @ s@ e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � Z dS )�UserDatabaseTestsMixina^ L{UserDatabaseTestsMixin} defines tests which apply to any user database implementation. Subclasses should mix it in, implement C{setUp} to create C{self.database} bound to a user database instance, and implement C{getExistingUserInfo} to return information about a user (such information should be unique per test method). c C s� t d�D ]�}| �� \}}}}}}}| j�|�} | �| j|� | �| j|� | �| j|� | �| j|� | �| j |� | �| j |� | �| j|� qdS )zc I{getpwuid} accepts a uid and returns the user record associated with it. � N)�range�getExistingUserInfo�databaser �assertEqual�pw_name� pw_passwd�pw_uid�pw_gid�pw_gecos�pw_dir�pw_shell� �self�i�username�password�uid�gid�gecos�dir�shell�entryr r r � test_getpwuid>