SILENT KILLERPanel

Current Path: > > opt > cloudlinux > venv > lib64 > python3.11 > site-packages > testfixtures > tests


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt/cloudlinux/venv/lib64/python3.11/site-packages/testfixtures/tests

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
test_django Directory - -
__init__.py File 64 bytes April 17 2025 13:10:58.
configparser-read.txt File 832 bytes April 17 2025 13:10:58.
configparser-write.txt File 775 bytes April 17 2025 13:10:58.
directory-contents.txt File 739 bytes April 17 2025 13:10:58.
sample1.py File 1137 bytes April 17 2025 13:10:58.
sample2.py File 412 bytes April 17 2025 13:10:58.
sample3.py File 43 bytes April 17 2025 13:10:58.
test_compare.py File 62813 bytes April 17 2025 13:10:58.
test_comparison.py File 22706 bytes April 17 2025 13:10:58.
test_components.py File 974 bytes April 17 2025 13:10:58.
test_date.py File 10659 bytes April 17 2025 13:10:58.
test_datetime.py File 16979 bytes April 17 2025 13:10:58.
test_diff.py File 892 bytes April 17 2025 13:10:58.
test_generator.py File 467 bytes April 17 2025 13:10:58.
test_log_capture.py File 7379 bytes April 17 2025 13:10:58.
test_logcapture.py File 19667 bytes April 17 2025 13:10:58.
test_mappingcomparison.py File 9651 bytes April 17 2025 13:10:58.
test_mock.py File 2245 bytes April 17 2025 13:10:58.
test_outputcapture.py File 4355 bytes April 17 2025 13:10:58.
test_popen.py File 23314 bytes April 17 2025 13:10:58.
test_popen_docs.py File 7684 bytes April 17 2025 13:10:58.
test_rangecomparison.py File 5330 bytes April 17 2025 13:10:58.
test_replace.py File 29971 bytes April 17 2025 13:10:58.
test_replacer.py File 3906 bytes April 17 2025 13:10:58.
test_roundcomparison.py File 4828 bytes April 17 2025 13:10:58.
test_sequencecomparison.py File 12368 bytes April 17 2025 13:10:58.
test_should_raise.py File 9967 bytes April 17 2025 13:10:58.
test_shouldwarn.py File 4619 bytes April 17 2025 13:10:58.
test_stringcomparison.py File 1354 bytes April 17 2025 13:10:58.
test_sybil.py File 4302 bytes April 17 2025 13:10:58.
test_tempdir.py File 2883 bytes April 17 2025 13:10:58.
test_tempdirectory.py File 11215 bytes April 17 2025 13:10:58.
test_time.py File 7734 bytes April 17 2025 13:10:58.
test_twisted.py File 5672 bytes April 17 2025 13:10:58.
test_wrap.py File 6576 bytes April 17 2025 13:10:58.

Reading File: //opt/cloudlinux/venv/lib64/python3.11/site-packages/testfixtures/tests/test_time.py

from datetime import timedelta
from typing import Type, cast
from unittest import TestCase
from testfixtures import mock_time, replace, compare, ShouldRaise
from .test_datetime import SampleTZInfo
from ..datetime import MockTime


class TestTime(TestCase):

    @replace('time.time', mock_time())
    def test_time_call(self):
        from time import time
        compare(time(), 978307200.0)
        compare(time(), 978307201.0)
        compare(time(), 978307203.0)

    @replace('time.time', mock_time(2002, 1, 1, 1, 2, 3))
    def test_time_supplied(self):
        from time import time
        compare(time(), 1009846923.0)

    @replace('time.time', mock_time(None))
    def test_time_sequence(self, t: Type[MockTime]):
        t.add(2002, 1, 1, 1, 0, 0)
        t.add(2002, 1, 1, 2, 0, 0)
        t.add(2002, 1, 1, 3, 0, 0)
        from time import time
        compare(time(), 1009846800.0)
        compare(time(), 1009850400.0)
        compare(time(), 1009854000.0)

    @replace('time.time', mock_time(None))
    def test_add_datetime_supplied(self, t: Type[MockTime]):
        from datetime import datetime
        from time import time
        t.add(datetime(2002, 1, 1, 2))
        compare(time(), 1009850400.0)
        tzinfo = SampleTZInfo()
        tzrepr = repr(tzinfo)
        with ShouldRaise(ValueError(
            'Cannot add datetime with tzinfo of %s as configured to use None' %(
                tzrepr
            ))):
            t.add(datetime(2001, 1, 1, tzinfo=tzinfo))

    def test_instantiate_with_datetime(self):
        from datetime import datetime
        t = mock_time(datetime(2002, 1, 1, 2))
        compare(t(), 1009850400.0)

    @replace('time.time', mock_time(None))
    def test_now_requested_longer_than_supplied(self, t: Type[MockTime]):
        t.add(2002, 1, 1, 1, 0, 0)
        t.add(2002, 1, 1, 2, 0, 0)
        from time import time
        compare(time(), 1009846800.0)
        compare(time(), 1009850400.0)
        compare(time(), 1009850401.0)
        compare(time(), 1009850403.0)

    @replace('time.time', mock_time())
    def test_call(self, t: Type[MockTime]):
        compare(t(), 978307200.0)
        from time import time
        compare(time(), 978307201.0)

    @replace('time.time', mock_time())
    def test_repr_time(self):
        from time import time
        compare(repr(time), "<class 'testfixtures.datetime.MockTime'>")

    @replace('time.time', mock_time(delta=10))
    def test_delta(self):
        from time import time
        compare(time(), 978307200.0)
        compare(time(), 978307210.0)
        compare(time(), 978307220.0)

    @replace('time.time', mock_time(delta_type='minutes'))
    def test_delta_type(self):
        from time import time
        compare(time(), 978307200.0)
        compare(time(), 978307260.0)
        compare(time(), 978307380.0)

    @replace('time.time', mock_time(None))
    def test_set(self):
        from time import time
        time = cast(Type[MockTime], time)
        time.set(2001, 1, 1, 1, 0, 1)
        compare(time(), 978310801.0)
        time.set(2002, 1, 1, 1, 0, 0)
        compare(time(), 1009846800.0)
        compare(time(), 1009846802.0)

    @replace('time.time', mock_time(None))
    def test_set_datetime_supplied(self, t: Type[MockTime]):
        from datetime import datetime
        from time import time
        t.set(datetime(2001, 1, 1, 1, 0, 1))
        compare(time(), 978310801.0)
        tzinfo = SampleTZInfo()
        tzrepr = repr(tzinfo)
        with ShouldRaise(ValueError(
            'Cannot add datetime with tzinfo of %s as configured to use None' %(
                tzrepr
            ))):
            t.set(datetime(2001, 1, 1, tzinfo=tzinfo))

    @replace('time.time', mock_time(None))
    def test_set_kw(self):
        from time import time
        time = cast(Type[MockTime], time)
        time.set(year=2001, month=1, day=1, hour=1, second=1)
        compare(time(), 978310801.0)

    @replace('time.time', mock_time(None))
    def test_set_kw_tzinfo(self):
        from time import time
        time = cast(Type[MockTime], time)
        with ShouldRaise(TypeError('Cannot add using tzinfo on MockTime')):
            time.set(year=2001, tzinfo=SampleTZInfo())

    @replace('time.time', mock_time(None))
    def test_set_args_tzinfo(self):
        from time import time
        time = cast(Type[MockTime], time)
        with ShouldRaise(TypeError('Cannot add using tzinfo on MockTime')):
            time.set(2002, 1, 2, 3, 4, 5, 6, SampleTZInfo())

    @replace('time.time', mock_time(None))
    def test_add_kw(self):
        from time import time
        time = cast(Type[MockTime], time)
        time.add(year=2001, month=1, day=1, hour=1, second=1)
        compare(time(), 978310801.0)

    @replace('time.time', mock_time(None))
    def test_add_tzinfo_kw(self):
        from time import time
        time = cast(Type[MockTime], time)
        with ShouldRaise(TypeError('Cannot add using tzinfo on MockTime')):
            time.add(year=2001, tzinfo=SampleTZInfo())

    @replace('time.time', mock_time(None))
    def test_add_tzinfo_args(self):
        from time import time
        time = cast(Type[MockTime], time)
        with ShouldRaise(TypeError('Cannot add using tzinfo on MockTime')):
            time.add(2001, 1, 2, 3, 4, 5, 6, SampleTZInfo())

    @replace('time.time', mock_time(2001, 1, 2, 3, 4, 5, 600000))
    def test_max_number_args(self):
        from time import time
        compare(time(), 978404645.6)

    def test_max_number_tzinfo(self):
        with ShouldRaise(TypeError(
            "You don't want to use tzinfo with test_time"
                )):
            mock_time(2001, 1, 2, 3, 4, 5, 6, SampleTZInfo())

    @replace('time.time', mock_time(2001, 1, 2))
    def test_min_number_args(self):
        from time import time
        compare(time(), 978393600.0)

    @replace('time.time', mock_time(
        year=2001,
        month=1,
        day=2,
        hour=3,
        minute=4,
        second=5,
        microsecond=6,
        ))
    def test_all_kw(self):
        from time import time
        compare(time(), 978404645.000006)

    def test_kw_tzinfo(self):
        with ShouldRaise(TypeError(
            "You don't want to use tzinfo with test_time"
                )):
            mock_time(year=2001, tzinfo=SampleTZInfo())

    def test_instance_tzinfo(self):
        from datetime import datetime
        with ShouldRaise(TypeError(
            "You don't want to use tzinfo with test_time"
                )):
            mock_time(datetime(2001, 1, 1, tzinfo=SampleTZInfo()))

    def test_subsecond_deltas(self):
        time = mock_time(delta=0.5)
        compare(time(), 978307200.0)
        compare(time(), 978307200.5)
        compare(time(), 978307201.0)

    def test_ms_deltas(self):
        time = mock_time(delta=1000, delta_type='microseconds')
        compare(time(), 978307200.0)
        compare(time(), 978307200.001)
        compare(time(), 978307200.002)

    def test_tick_when_static(self):
        time = mock_time(delta=0)
        compare(time(), expected=978307200.0)
        time.tick(seconds=1)
        compare(time(), expected=978307201.0)

    def test_tick_when_dynamic(self):
        # hopefully not that common?
        time = mock_time()
        compare(time(), expected=978307200.0)
        time.tick(seconds=1)
        compare(time(), expected=978307202.0)

    def test_tick_with_timedelta_instance(self):
        time = mock_time(delta=0)
        compare(time(), expected=978307200.0)
        time.tick(timedelta(seconds=1))
        compare(time(), expected=978307201.0)

    def test_old_import(self):
        from testfixtures import test_time
        assert test_time is mock_time

SILENT KILLER Tool