File: //lib/python3/dist-packages/twisted/python/test/__pycache__/test_systemd.cpython-310.pyc
o
�b� � @ sz d Z ddlZddlmZ ddlmZ G dd� d�ZG dd� d�ZG d d
� d
�ZG dd� deee�Z G d
d� deee�Z
dS )z&
Tests for L{twisted.python.systemd}.
� N)� ListenFDs)�TestCasec @ � e Zd ZdZdd� Zdd� ZdS )�InheritedDescriptorsMixinz�
Mixin for a L{TestCase} subclass which defines test methods for some kind of
systemd sd-daemon class. In particular, it defines tests for a
C{inheritedDescriptors} method.
c C s$ | � dd�}| �g d�|�� � dS )z�
C{inheritedDescriptors} returns a list of integers giving the file
descriptors which were inherited from systemd.
� � )r � � N�� getDaemon�assertEqual�inheritedDescriptors��self�sddaemon� r �B/usr/lib/python3/dist-packages/twisted/python/test/test_systemd.py�test_inheritedDescriptors s z3InheritedDescriptorsMixin.test_inheritedDescriptorsc C s$ | � dd�}| �|�� |�� � dS )zW
Any subsequent calls to C{inheritedDescriptors} return the same list.
r r Nr
r r r r �
test_repeated s �z'InheritedDescriptorsMixin.test_repeatedN)�__name__�
__module__�__qualname__�__doc__r r r r r r r s r c @ s e Zd ZdZdd� ZdS )�MemoryOnlyMixinz�
Mixin for a L{TestCase} subclass which creates creating a fake, in-memory
implementation of C{inheritedDescriptors}. This provides verification that
the fake behaves in a compatible way with the real implementation.
c C s t t||| ��S )a
Invent C{count} new I{file descriptors} (actually integers, attached to
no real file description), starting at C{start}. Construct and return a
new L{ListenFDs} which will claim those integers represent inherited
file descriptors.
)r �range)r �start�countr r r r / s zMemoryOnlyMixin.getDaemonN)r r r r r r r r r r ( s r c @ r )�EnvironmentMixinaV
Mixin for a L{TestCase} subclass which creates a real implementation of
C{inheritedDescriptors} which is based on the environment variables set by
systemd. To facilitate testing, this mixin will also create a fake
environment dictionary and add keys to it to make it look as if some
descriptors have been inherited.
c C s&