File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/_test.tar
Back
test_core.py 0000644 00000005421 15030211240 0007073 0 ustar 00 from .._core import Automaton, NoTransition from unittest import TestCase class CoreTests(TestCase): """ Tests for Automat's (currently private, implementation detail) core. """ def test_NoTransition(self): """ A L{NoTransition} exception describes the state and input symbol that caused it. """ # NoTransition requires two arguments with self.assertRaises(TypeError): NoTransition() state = "current-state" symbol = "transitionless-symbol" noTransitionException = NoTransition(state=state, symbol=symbol) self.assertIs(noTransitionException.symbol, symbol) self.assertIn(state, str(noTransitionException)) self.assertIn(symbol, str(noTransitionException)) def test_noOutputForInput(self): """ L{Automaton.outputForInput} raises L{NoTransition} if no transition for that input is defined. """ a = Automaton() self.assertRaises(NoTransition, a.outputForInput, "no-state", "no-symbol") def test_oneTransition(self): """ L{Automaton.addTransition} adds its input symbol to L{Automaton.inputAlphabet}, all its outputs to L{Automaton.outputAlphabet}, and causes L{Automaton.outputForInput} to start returning the new state and output symbols. """ a = Automaton() a.addTransition("beginning", "begin", "ending", ["end"]) self.assertEqual(a.inputAlphabet(), {"begin"}) self.assertEqual(a.outputAlphabet(), {"end"}) self.assertEqual(a.outputForInput("beginning", "begin"), ("ending", ["end"])) self.assertEqual(a.states(), {"beginning", "ending"}) def test_oneTransition_nonIterableOutputs(self): """ L{Automaton.addTransition} raises a TypeError when given outputs that aren't iterable and doesn't add any transitions. """ a = Automaton() nonIterableOutputs = 1 self.assertRaises( TypeError, a.addTransition, "fromState", "viaSymbol", "toState", nonIterableOutputs) self.assertFalse(a.inputAlphabet()) self.assertFalse(a.outputAlphabet()) self.assertFalse(a.states()) self.assertFalse(a.allTransitions()) def test_initialState(self): """ L{Automaton.initialState} is a descriptor that sets the initial state if it's not yet set, and raises L{ValueError} if it is. """ a = Automaton() a.initialState = "a state" self.assertEqual(a.initialState, "a state") with self.assertRaises(ValueError): a.initialState = "another state" # FIXME: addTransition for transition that's been added before __pycache__/__init__.cpython-310.pyc 0000644 00000000225 15030211240 0013177 0 ustar 00 o q+WZ � @ s d S )N� r r r �8/usr/lib/python3/dist-packages/automat/_test/__init__.py�<module> s __pycache__/test_discover.cpython-310.pyc 0000644 00000051334 15030211240 0014324 0 ustar 00 o q+WZVU � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZmZ d dl Z dd� Z G dd� de�Zee � d�G dd � d e��Zee � d�G d d� de��Z ee � d�G dd � d e��Zee � d�G dd� de��ZdS )� N)�skipIf�TestCasec C s$ zt d� W dS ty Y dS w )N�twistedFT)� __import__�ImportError� r r �=/usr/lib/python3/dist-packages/automat/_test/test_discover.py�isTwistedInstalled s ��r c s\ e Zd ZdZ� fdd�Z� fdd�Zdd� Zdd � Zd d� Zdd � Z dd� Z dd� Z� ZS )�_WritesPythonModuleszG A helper that enables generating Python module test fixtures. c sv t t| ��� ddlm}m} ddlm} || _|| _|| _tt j �� �| _t j d d � | _t�� | _| �| j� d S )Nr )� getModule� PythonPath)�FilePath)�superr �setUp�twisted.python.modulesr r �twisted.python.filepathr �set�sys�modules�keys�originalSysModules�path�savedSysPath�tempfile�mkdtemp�pathDir�makeImportable)�selfr r r �� __class__r r r s z_WritesPythonModules.setUpc sR t t| ��� | jtjd d �<