Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kojimboy committed Sep 13, 2022
1 parent 0b90e7c commit eb72dba
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
15 changes: 1 addition & 14 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.


def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_hi('PyCharm')

# See PyCharm help at https://www.jetbrains.com/help/pycharm/
print("Hello_World")
24 changes: 24 additions & 0 deletions tests/test_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest


def test_list_len():
list = [1, 2, 3, 4]
assert len(list) == 4


@pytest.mark.parametrize("test_data, expected_result", [([0, 1, 2, 3, 4], [0, 1, 2, 3, 4]), # отсортированные положит числа
([4, 3, 2, 1, 0], [0, 1, 2, 3, 4]), # неотсортированные положит числа
([-4, -3, -2, -1, 0], [-4, -3, -2, -1, 0]), # отсортированные негатив числа
([-3, -4, -1, -2, 0], [-4, -3, -2, -1, 0]), # неотсортированные негатив числа
([-4, 5, 1, 1, 0], [-4, 0, 1, 1, 5])]) # неотсортированные негатив и позитив числа
def test_list_sort(test_data, expected_result):
list = test_data
list.sort()
assert list == expected_result

def test_list_remove():
list = [1,2,3]
try:
assert list.remove(4)
except ValueError:
pass
23 changes: 23 additions & 0 deletions tests/test_set.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest


def test_set_add_new_element():
a = {1, 2, 2, 3, 0}
assert 3 in a


@pytest.mark.parametrize("test_data1, test_data2, expected_result", [({1, 2, 2, 4}, {5, 6, 1, 0}, {1}), #входит один элемент
({1, 2, 2, 4}, {5, 6, 6, 0}, set()), #ни один не входит
({1, 2, 2, 3, 4}, {1, 2, 6, 7, 3}, {1, 2, 3}), #входят несколько элементов
])
def test_set_intersection(test_data1, test_data2, expected_result):
a = test_data1
b = test_data2
assert a.intersection(b) == expected_result


def test_set_from_list():
try:
assert set([[1, 2], [2, 3], [1, 2], [2, 5]])
except TypeError:
pass

0 comments on commit eb72dba

Please sign in to comment.