per page, with , order by , clip by
Results of 1 - 10 of about 113 for Method (0.009 sec.)
unittest.mock --- モックオブジェクトライブラリ 15324
unittest.mock --- モックオブジェクトライブラリ Added in version 3.3. ソースコード: Lib/unittest/mock.py unittest.mock は Python でテストを行うためのライブラリです。 テスト対象のシステムの一部をモックオブジェクトに置き換え、どのように使われた ... よう使用されたかについてアサートできます: >>> from unittest.mock import MagicMock >>> thing = ProductionClass () >>> thing . method = MagicMock ( return_value = 3 ) >>> thing . method ( 3 , 4 , 5 , key = 'value' ) 3 >>> thing . method . assert_called_wit ... tch() デコレータと同様に with 文でコンテキストマネージャーとして使用できます: >>> with patch . object ( ProductionClass , 'method' , return_value = None ) as mock_method : ... thing = ProductionClass () ... thing . method ( 1 , 2 , 3 ) ... >>> mock_met ... 照してください。 assert_called ( ) モックが少なくとも一度は呼び出されたことをアサートします。 >>> mock = Mock () >>> mock . method () <Mock name='mock.method()' id='...'> >>> mock . method . assert_called () Added in version 3.6. assert_called_once ( ) ...
https://man.mtool.work/python/3.14/library/unittest.mock.html
unittest.mock --- 入門 13155
unittest.mock --- 入門 Added in version 3.3. Mock を使う モックでメソッドにパッチを当てる 一般的な Mock の使い方の中には次のものがあります: メソッドにパッチを当てる オブジェクトに対するメソッド呼び出しを記録する システムの他の部分からメソッ ... び出されたかどうかを確認するために、そのオブジェクトのメソッドを置き換えることができます: >>> real = SomeClass () >>> real . method = MagicMock ( name = 'method' ) >>> real . method ( 3 , 4 , 5 , key = 'value' ) <MagicMock name='method()' id='...'> モック ... (上の例では real.method )が利用された場合、どう使われたかを assert できるようにする属性やメソッドがモックにあります。 注釈 この例のような場合、たい ... nce_with() メソッドを使ってそのメソッドが正しい引数で呼び出されたかどうかをチェックできます。 次の例では ProductionClass().method が something メソッドを呼び出したことをテストしています: >>> class ProductionClass : ... def method ( self ): ... self . s ...
https://man.mtool.work/python/3.14/library/unittest.mock-examples.html
The Python Profilers 9686
The Python Profilers Source code: Lib/profile.py and Lib/pstats.py Introduction to the profilers cProfile and profile provide deterministic profiling of Python programs. A profile is a set of statistics that describes how often and for how ... mulative time ncalls tottime percall cumtime percall filename : lineno ( function ) 1 0.000 0.000 0.002 0.002 { built - in method builtins . exec } 1 0.000 0.000 0.001 0.001 < string > : 1 ( < module > ) 1 0.000 0.000 0.001 0.001 __init__ . py : 250 ( ... tion to cProfile . Added in version 3.8: Added the -m option to profile . The pstats module's Stats class has a variety of methods for manipulating and printing the data saved into a profile results file: import pstats from pstats import SortKey p = ps ... tats . Stats ( 'restats' ) p . strip_dirs () . sort_stats ( - 1 ) . print_stats () The strip_dirs() method removed the extraneous path from all the module names. The sort_stats() method sorted all the entries according to the sta ...
https://man.mtool.work/python/3.14/library/profile.html
collections.abc --- コンテナの抽象基底クラス 8564
collections.abc --- コンテナの抽象基底クラス Added in version 3.3: 以前はこのモジュールは collections モジュールの一部でした。 ソースコード: Lib/_collections_abc.py このモジュールは、 抽象基底クラス を提供します。抽象基底クラスは、クラスが特 ... ます。 他のメソッドも必要に応じて追加できます: class C ( Sequence ): # Direct inheritance def __init__ ( self ): ... # Extra method not required by the ABC def __getitem__ ( self , index ): ... # Required abstract method def __len__ ( self ): ... # Requi ... red abstract method def count ( self , value ): ... # Optionally override a mixin method >>> issubclass ( C , Sequence ) True >>> isinstance ( ... ただし、API の他の部分から自動的に導かれるメソッドは例外です: class D : # No inheritance def __init__ ( self ): ... # Extra method not required by the ABC def __getitem__ ( self , index ): ... # Abstract method def __len__ ( self ): ... # Abstract metho ...
https://man.mtool.work/python/3.14/library/collections.abc.html
urllib.request --- URL を開くための拡張可能なライブラリ 8387
urllib.request --- URL を開くための拡張可能なライブラリ ソースコード: Lib/urllib/request.py urllib.request モジュールは、Basic 認証や Digest 認証、リダイレクト、Cookie などが絡む複雑な状況で URL (主に HTTP) を開くための関数とクラスを定義して ... ェクトを使用して取得できます。 デフォルトの opener は、リクエストオブジェクトから取得した引数 fullurl 、 data 、 headers 、 method とともに、 監査イベント urllib.Request を発生させます。 バージョン 3.2 で変更: cafile および capath が追加されました。 HTT ... 文字と大文字の環境変数が両方存在する (そして値が一致しない) なら、小文字の環境変数が優先されます。 注釈 もし環境変数 REQUEST_METHOD が設定されていたら (これは通常スクリプトが CGI 環境で動いていることを示しています)、環境変数 HTTP_PROXY (大文字の _PROXY ) ... ています: class urllib.request. Request ( url , data = None , headers = {} , origin_req_host = None , unverifiable = False , method = None ) このクラスは URL リクエストを抽象化したものです。 url は、適切にエンコードされた有効な URL を含む文字列でなければ ...
https://man.mtool.work/python/3.14/library/urllib.request.html
multiprocessing --- プロセスベースの並列処理 7958
multiprocessing --- プロセスベースの並列処理 ソースコード: Lib/multiprocessing/ 利用可能な環境 : not Android, not iOS, not WASI. このモジュールは モバイルプラットフォーム と WebAssemblyプラットフォーム をサポートしません。 はじめに multipro ... プラットフォームでも、デフォルトの開始方式ではなくなりました。 fork を必要とするコードでは、 get_context() または set_start_method() で明示的に指定しなければなりません。 バージョン 3.12 で変更: プロセスが複数のスレッドを持つと Python が検出できる場合、こ ... ロセスでよく起こる互換性の問題を避けるためです。 gh-84559 を参照してください。 On POSIX using the spawn or forkserver start methods will also start a resource tracker process which tracks the unlinked named system resources (such as named semaphores or ... ments occupy some space in the main memory.) 開始方式はメインモジュールの if __name__ == '__main__' 節内で、関数 set_start_method() によって指定します。以下に例を示します: import multiprocessing as mp def foo ( q ): q . put ( 'hello' ) if __name__ == ' ...
https://man.mtool.work/python/3.14/library/multiprocessing.html
拡張モジュールを分離する 7693
拡張モジュールを分離する 概要 従来、Python 拡張モジュールの状態は、プロセス全体をスコープとする C の static 変数に保持されていました。 このドキュメントでは、プロセスごとの状態が抱える問題と、より安全な方法であるモジュールごとの状態について説 ... ) def get_defining_class ( self ): return __class__ class Sub ( Base ): pass メソッドが「定義クラス」を取得するには、 METH_METHOD | METH_FASTCALL | METH_KEYWORDS 呼び出し規約 と、それに対応する PyCMethod シグネチャを使う必要があります。 PyObject * PyCM ... ethod ( PyObject * self , // object the method was called on PyTypeObject * defining_class , // defining class PyObject * const * args , // C array of arguments Py_ssize ... たら、 PyType_GetModuleState() を呼び出して、関連付けられたモジュールの状態を取得します。 例えば: static PyObject * example_method ( PyObject * self , PyTypeObject * defining_class , PyObject * const * args , Py_ssize_t nargs , PyObject * kwnames ) { my ...
https://man.mtool.work/python/3.14/howto/isolating-extensions.html
weakref --- 弱参照 7517
weakref --- 弱参照 ソースコード: Lib/weakref.py weakref モジュールを使うと、Python プログラムからオブジェクトへの 弱参照 を作成できます。 以下では、用語リファレント( referent ) は弱参照が参照するオブジェクトを意味します。 オブジェクトへの弱 ... ( [ elements ] ) 要素への弱参照を持つ集合型。要素への強参照が無くなったときに、その要素は削除されます。 class weakref. WeakMethod ( method [ , callback ] ) 束縛されたメソッド (クラスで定義され、インスタンスから取得されるメソッド) への弱参照をシミュレー ... トする、 ref のカスタムサブクラスです。 束縛されたメソッドは短命なので、通常の弱参照では保持し続けられません。 WeakMethod には、オブジェクトまたは元の関数のどちらか一方が破棄されるまで、束縛されたメソッドを再作成するための特別なコードがあります ... 。 >>> class C : ... def method ( self ): ... print ( "method called!" ) ... >>> c = C () >>> r = weakref . ref ( c . method ) >>> r () >>> r = weakref . ...
https://man.mtool.work/python/3.14/library/weakref.html
共通のオブジェクト構造体 (common object structure) 7264
共通のオブジェクト構造体 (common object structure) Python のオブジェクト型の定義には、多数の構造体が使われます。 この節では、それらの構造体と使い方を説明します。 基本のオブジェクト型とマクロ すべての Python オブジェクトは、メモリ上の表現の先 ... PyCFunctionFastWithKeywords ( PyObject * self , PyObject * const * args , Py_ssize_t nargs , PyObject * kwnames ); type PyCMethod METH_METHOD | METH_FASTCALL | METH_KEYWORDS のシグネチャを持つ Python の呼び出し可能オブジェクトを C で実装するための関数の ... 型です。 シグネチャは次のとおりです。 PyObject * PyCMethod ( PyObject * self , PyTypeObject * defining_class , PyObject * const * args , Py_ssize_t nargs , PyObject * kwnames ) Adde ... d in version 3.9. type PyMethodDef 次に属します: Stable ABI (すべてのメンバーを含む). 拡張型のメソッドを記述する際に用いる構造体です。この構造体には 4 つの ...
https://man.mtool.work/python/3.14/c-api/structures.html
cmd --- 行指向のコマンドインタープリターのサポート 7176
cmd --- 行指向のコマンドインタープリターのサポート ソースコード: Lib/cmd.py Cmd クラスでは、行指向のコマンドインタープリタを書くための簡単なフレームワークを提供します。テストハーネスや管理ツール、そして、後により洗練されたインターフェイスで ... d typically presents the user with an interactive prompt, reads input one line at a time, and dispatches each command to a method named do_ followed by the command name. For example, the help command is handled by the do_help() method. Apart from the b ... uilt-in help command, most of the interpreter's behavior is defined by the do_* methods you add in your own subclass. class cmd. Cmd ( completekey = 'tab' , stdin = None , stdout = None ) Cmd インスタンス、ある ... yped in response to the prompt. This may be overridden, but should not normally need to be; see the precmd() and postcmd() methods for useful execution hooks. The return value is a flag indicating whether interpretation of commands by the interpreter s ...
https://man.mtool.work/python/3.14/library/cmd.html
PREV 1 2 3 4 5 6 7 8 9 10 NEXT