Want to use assert in following python code


#1
import os
from pytest import raises
import pytest
import difflib
import pathlib

def file_comparison():
    full_dir_path = pathlib.Path(os.path.dirname(os.path.realpath(__file__)))

    file_name_1 = full_dir_path / 'PDI_EXTRACT_TEST.txt'
    print(file_name_1)
    file_name_2 = full_dir_path / '20190212141909_DE_V_CSV_EXTRACT_TEST.csv'
    print(file_name_2)
    with open(str(file_name_1), 'r') as file1:
        content1 = file1.read()

    with open(str(file_name_2), 'r') as file2:
        content2 = file2.read()


    if content1 == content2:
        print('files are same')
    else:
        text1 = open(file_name_1).readlines()
        text2 = open(file_name_2).readlines()
        text1.sort()
        text2.sort()
        for line in difflib.unified_diff(text1, text2):
            print(line)


if __name__ == "__main__":

    file_comparison()

I have the above code in the if else block I want to use assert , how can I do it can someone please help me here


#2

You can just assert anything that should be true like this:

assert True, "This will work."

vs.

assert False, "This will not work."

Also, when you put code on the forum do this:

```
my code
```

So that it formats correctly.