<commit_before>#!/usr/bin/python3
"""Tests for scripts/delete.py."""
#
# (C) Pywikibot team, 2014-2022
#
# Distributed under the terms of the MIT license.
#
import unittest
from contextlib import suppress

import pywikibot
import pywikibot.page
from scripts import delete
from tests.aspects import ScriptMainTestCase
from tests.utils import empty_sites


class TestDeletionBotWrite(ScriptMainTestCase):

    """Test deletionbot script."""

    family = 'wikipedia'
    code = 'test'

    sysop = True
    write = True

    def test_delete(self):
        """Test deletionbot on the test wiki."""
        site = self.get_site()
        cat = pywikibot.Category(site, 'Pywikibot Delete Test')
        delete.main('-cat:Pywikibot_Delete_Test', '-always')
        self.assertEmpty(list(cat.members()))
        delete.main('-page:User:Unicodesnowman/DeleteTest1', '-always',
                    '-undelete', '-summary=pywikibot unit tests')
        delete.main('-page:User:Unicodesnowman/DeleteTest2', '-always',
                    '-undelete', '-summary=pywikibot unit tests')
        self.assertLength(list(cat.members()), 2)

    def test_undelete_existing(self):
        """Test undeleting an existing page."""
        site = self.get_site()
        p1 = pywikibot.Page(site, 'User:Unicodesnowman/ExistingPage')
        if not p1.exists():
            p1.text = 'pywikibot unit test page'
            p1.save('unit test', botflag=True)
        delete.main('-page:User:Unicodesnowman/ExistingPage', '-always',
                    '-undelete', '-summary=pywikibot unit tests')


class TestDeletionBotUser(ScriptMainTestCase):

    """Test deletionbot as a user (not sysop)."""

    family = 'wikipedia'
    code = 'test'

    login = True
    write = True

    def test_delete_mark(self):
        """Test marking User:Unicodesnowman/DeleteMark for deletion."""
        site = self.get_site()<commit_msg>[skip actions] Use assertIsEmpty method with deletionbot_tests.py<commit_after>#!/usr/bin/python3
"""Tests for scripts/delete.py."""
#
# (C) Pywikibot team, 2014-2022
#
# Distributed under the terms of the MIT license.
#
import unittest
from contextlib import suppress

import pywikibot
import pywikibot.page
from scripts import delete
from tests.aspects import ScriptMainTestCase
from tests.utils import empty_sites


class TestDeletionBotWrite(ScriptMainTestCase):

    """Test deletionbot script."""

    family = 'wikipedia'
    code = 'test'

    sysop = True
    write = True

    def test_delete(self):
        """Test deletionbot on the test wiki."""
        site = self.get_site()
        cat = pywikibot.Category(site, 'Pywikibot Delete Test')
        delete.main('-cat:Pywikibot_Delete_Test', '-always')
        self.assertIsEmpty(list(cat.members()))
        delete.main('-page:User:Unicodesnowman/DeleteTest1', '-always',
                    '-undelete', '-summary=pywikibot unit tests')
        delete.main('-page:User:Unicodesnowman/DeleteTest2', '-always',
                    '-undelete', '-summary=pywikibot unit tests')
        self.assertLength(list(cat.members()), 2)

    def test_undelete_existing(self):
        """Test undeleting an existing page."""
        site = self.get_site()
        p1 = pywikibot.Page(site, 'User:Unicodesnowman/ExistingPage')
        if not p1.exists():
            p1.text = 'pywikibot unit test page'
            p1.save('unit test', botflag=True)
        delete.main('-page:User:Unicodesnowman/ExistingPage', '-always',
                    '-undelete', '-summary=pywikibot unit tests')


class TestDeletionBotUser(ScriptMainTestCase):

    """Test deletionbot as a user (not sysop)."""

    family = 'wikipedia'
    code = 'test'

    login = True
    write = True

    def test_delete_mark(self):
        """Test marking User:Unicodesnowman/DeleteMark for deletion."""
        site = self.get_site()
{'fraction_non_alphanumeric': 0.12376751427088739, 'fraction_numerical': 0.008303061754021795, 'mean_word_length': 3.007276507276507, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3714176', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1145, 'n_words': 281}