Python? Unittest ?? Pytest ??? ??? ??? ??? ? ???? ??????
Jun 19, 2025 am 01:10 AMPython? Unittest ? Pytest? ??? ? ???? ??, ?? ? ??? ????? ? ?? ?? ???? ??? ??? ?????. 1. ??? ??? ?? ??? ???? ??? ??? ??? ?????. UnitTest? ??? ??? ???? ???? Test \ _? ???? ???? ?????. Pytest? ? ???? Test \ _? ???? ?? ? ????. 2. ??? ?? ?? ? ?? ? ??? ??? ????. UnitTest? Assertequal, AssertTrue ? ?? ??? ???? ?? Pytest? ??? Assert ?? ???? ?? ?? ??? ???? ?????. 3. ? ? ?? ?? ? ??? ?????? ????? ????. ?? ???? ?? ? ?? ??? ?? ???? Pytest? ???? ??? ??? ?? ?? ?????? ?? ?????. 4. ??? ???? ???? ????. UnitTest? Coverage.py ? CI/CD ???? ?? ?? ??? ??? ?? ?? ? ? ????. Pytest?? ??? ?? ?? ?? ? ?? ??? ?????? ??? ??? HTML ??? ??, ?? ??, ?? ???? ? ?? ?? ??? ?????? ?? ????? ????.
Python? unittest
? pytest
?? ?? ???? ??? ??? ?? ? ????, ?? ?? ???? ?? ??, ?? ? ??? ? ????. ??? ???? ??? ?????? ?? ?? ??, ?? ? ??, ?? ???? ?????.
1. ?? ??? ?? ??? ??? ??
? ??? ??? ???? ??? ???? ???? ??? ???? ???? ???? ?? ??? ? ????.
-
UnitTest??? Subclassing
unittest.TestCase
?? ??? ??? ????test_
? ???? ? ??? ??? ???? ?????.import unittest ??? testmathFunctions (unittest.testcase) : def test_addition (self) : self.assertequal (1 1, 2)
Pytest??? ? ?????.
test_
? ???? ??? ?????. ?? ???? ???????? ?? ? ??? ???? ????.def test_addition () : ASSERT 1 1 == 2
? ? ?????? ?? ???? ?? ??? ???? ?? ????? ????? ??? ? ?? ???? ??????? ?? ??? ?? ???? ?? ????.
2. ?? ?? ? ??
?? ?? ??? ??? ???? ?? ???? ???? ? ??? ?? ?? ??? ??? ?????.
UnitTest?
assertEqual
,assertTrue
,assertRaises
?? ?? ???? ??? ??? ???, ?? ?? ? ? ??? ?? ???? ?????.Pytest? ??? ? Python
assert
?? ????? ??? ???? ??????. ??? ???? ???? ?? ??? ???? ?? ??? ??? ?????? ? ? ????.
?? ??:
def test_list_length () : ?? = [1, 2, 3] assert len ??(result) == 2 # pytest ?? ???? ?? ??? ?????.
??? ??? ? ??? ???? ?? ???? ????.
3. ?? ? ????? ??
???? ???? ?? (??????? ????? ?? ??? ???? ?) ??? ?? ??? ??????, ? ??? ??? ???? ???? ???? ? ??????.
UnitTest ??? ??? ??? ???
setUp()
?tearDown()
???? ???? ?? ??? ?? ? ?? ??? ?????.Pytest ??
@pytest.fixture()
Decorator? ???? ?? ??? ???? ??? ? ???? ??? ?????.
pytest? ????? @pytest.fixture def sample_data () : ?? { "??": "Alice", "Age": 30} def test_user_age (sample_data) : Assert Sample_Data [ "Age"]> 18
??? ?? ??? ??? ? ??? (?? ??, ??? ??, ?? ?? ?) ??? ??? ??? ?? ??? ? ? ????.
4. ??? ??? ? ????
? ??? ??? ?? ???? ????? ??? ??? ??? ????.
UnitTest?
coverage.py
? ?? ??? ?? ???? ? ?? ??? ??? ???? CI/CD ???? ?? ??? ? ?????.-
Pytest? ?? ??, HTML ???, ??, Django/Flask Integration ?? ??? ??? ???? ???? ????. ?? ??:
-
pytest-html
??? ???? ?????. -
pytest-xdist
???? ??? ?????. -
pytest-cov
?? ?? ??? ?????.
-
? ???? ??? ?? ????? ??? ?? ?? ?? ? ?? ??? ????? ?? ? ? ??? ?????.
??? ?? ???? ? ?? ?? ???? unittest
? pytest
?? ?????? ??? ??? ?????. ??? ??? ??? ????. unittest
? ????? ????? (Java/Junit?? ? ?????? ????). pytest
? ?????? ???? ????. ?? ???, ??? ??? ?? ?? ??? ??? ? ??? ?????.
????? ?? ??.
? ??? Python? Unittest ?? Pytest ??? ??? ??? ??? ? ???? ??????? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

AI? ??? ??? ?? ?? ? ?? ???? ????? ?? ??? ??????. 1. Baidu, Tencent API ?? ?? ?? NLP ?????? ?? ??? AI ?? ?? API? ??????. 2. PHP? ? ?? guzzle? ?? API? ???? ?? ??? ??????. 3. ?? ????? ?? ?? ??? ???? ???? ???? ??? ??? ? ????. 4. ?? ?? ? ?? ???? ?? PHP-L ? PHP_CODESNIFFER? ??????. 5. ???? ????? ???? ?? ?? ??? ?????? ??? ??????. AIAPI? ??? ? ???, ?? ??, ?? ? PHP ?? ??? ??? ???. ?? ???? PSR ??? ???, ??? ????? ????, ?? ??? ???, ????? ??? ????, X? ???????.

Seaborn 's Loctplot? ???? ? ?? ?? ??? ??? ???? ??????. 2. ?? ???? sns.jointPlot (data = tips, x = "total_bill", y = "tip", ?? = "scatter")? ?? ?????. ??? ????? ?????? ??? ??? ?????. 3. ???? ?? ??? ??? = "reg"? ???? marginal_kws? ???? ?? ?? ???? ?????. 4. ??? ??? ? ?? "Hex"? ???? ?? ????.

??? ??? ".join (Words)? ?? join () ???? ?? ? ? ????. 2. ?? ??? ???? ?? MAP (str, ??) ?? [str (x) forxinnumbers]??? ???? ???????. 3. ?? ?? ??? ???? ??? ??? ?????? ???? ?? ?? ? ? ????. 4. '|'.join (f "[{item}]"furiteminitems) ??? ?? join ()? ?? ? ??? ????? ??? ?? ??? ??? ? ????.

PyoDBC ?? : PipinStallPyODBC ??? ???? ?????? ??????. 2. SQLSERVER ?? : PYODBC.connect () ???? ?? ????, ??, ??????, UID/PWD ?? Trusted_Connection? ?? ? ?? ???? ???? SQL ?? ?? Windows ??? ?? ?????. 3. ??? ????? ?????? : pyodbc.drivers ()? ???? 'sqlserver'? ?? ? ???? ??? ????? ??? ???? ??? 'sqlserver ? Odbcdriver17? ?? ??? ???? ??? ????? ??????. 4. ?? ???? ? ?? ??

pandas.melt ()? ???? ?? ???? ? ???? ???? ? ?????. ?? ID_VARS? ???? ? ? ??? ???? ????. ??, 4.Value_name = 'score'? ?? ?? ? ? ??? ???? ????? ??, ?? ? ??? ??? ? ?? ?????.

pythontanbeoptimizedformemory-boundoperations? Headgroughgenerations, ??? ? ??? ??, ? ManagingObjectLifetimes.first, usegeneratorsinsteadoflistStoprocessLargedAtasetSoneitematime, theintintomemory.second? ?????

?? ??, ??? ? ??? ??? ?? ? ContactForm ??? ?????. 2.????, ?? ??? ?? ??? ???? ????, ??? ?? ? ? cleaned_data? ???? ??? ?????. ??? ??? ? ??? ??????. 3. ????? {{form.as_p}}? ???? ??? ????? {%csrf_token%}? ???? CSRF ??? ?????. 4. URL ???? Point / Contact / Contact_View??? ?????. modelform? ???? ??? ?? ???? ??? ??? ??????. ?? ?? ??? ??, HTML ??? ? ?? ????? ?? ??? ????, ?? ??? ?? ??? ?? ??? ?????.

?? ?? ?? ? ?? ?? ??? ??? ??? ???? ?? ???? ?? ???? ???? ?? ?????. ?? ??? ?? ???? ??? ?, ? ?? ??? ????? ?? ???? ??? ? ??? ?? ??? ???? ??? ????. ???? ??? ??? ???? ?? ?? ?? ??? ???? ????? ????? ???? ?????? ????. ??? ??? ?? ??? ?????? ???? ?? ?? ??? ?????. cryptocurrency ???? ??? ?? ??? ?? ?? ??? ? ???? ??? ???? ?? ?? ?? ????. ?? ?? ??? ?? ?? ??? 24 ?? ?? ???? ??? ??, ?? ??? ?? ? ?? ?????? ?? ?????. ? ??? ?? ??? ?? ?? ?? ??? ??? ???? ?????.
