pywincffi.dev package

Submodules

pywincffi.dev.lint module

Lint Utilities

Provides some help to pylint so static analysis can be made aware of some constants and functions that we define in headers.

pywincffi.dev.lint.constants_in_file(path)[source]

Returns a set of constants in the given file path

pywincffi.dev.lint.functions_in_file(path)[source]

Returns a set of functions defined in the given file path

pywincffi.dev.lint.register(_)[source]

An entrypoint that pylint uses to search for and register plugins with the given linter

pywincffi.dev.lint.transform(cls, constants=None, functions=None)[source]

Transforms class objects from pylint so they’re aware of extra attributes that are not present when being statically analyzed.

pywincffi.dev.release module

pywincffi.dev.testutil module

Test Utility

This module is used by the unittests.

class pywincffi.dev.testutil.LibraryWrapper(library, attributes)[source]

Bases: object

Used by TestCase.mock_library() to replace specific attributes on a compiled library.

class pywincffi.dev.testutil.SharedState[source]

Bases: object

Contains some state data which is shared across multiple TestCase instances. This is kept outside of the test case class itself so it can’t be inadvertently modified by a test or fixture.

HAS_INTERNET = None
ffi = None
kernel32 = None
ws2_32 = None
class pywincffi.dev.testutil.TestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

A base class for all test cases. By default the core test case just provides some extra functionality.

GetLastError()[source]

Returns a tuple containing output from the Windows GetLastError function and the associated error message. The error message will be None if GetLastError() returns 0.

HAS_INTERNET = None
INTERNET_HOSTS = ('github.com', 'readthedocs.org', 'example.com')
INTERNET_PORT = 80
REQUIRES_INTERNET = False
SetLastError(errno)[source]

Wrapper for SetLastError()

WSAGetLastError()[source]

Returns a tuple containing output from the Windows WSAGetLastError function and the associated error message. The error message will be None if WSAGetLastError() returns 0.

WSASetLastError(errno)[source]

Wrapper for WSASetLastError()

assert_last_error(errno)[source]

This function will assert that the last unhandled error was errno. After the check the last error will be reset to zero.

Parameters:errno (int) – The expected value from GetLastError.
create_python_process(command)[source]

Creates a Python process that run command

ffi = None
kernel32 = None
maybe_assert_last_error(errno)[source]

This function is similar to assert_last_error() except it won’t fail if the current error number is already 0.

random_string(length)[source]

Returns a random string as long as length. The first character will always be a letter. All other characters will be A-F, A-F or 0-9.

setUp()[source]
classmethod setUpClass()[source]
unhandled_error_check()[source]

A cleanup step which ensures that there are not any uncaught API errors left over. Unhandled errors could be a sign of an unhandled testing artifact, improper API usage or other problem. In any case, unhandled errors are often a source of test flake.

ws2_32 = None
pywincffi.dev.testutil.mock_library(**attributes)[source]

Used to replace an attribute the library that dist.load() returns. Useful for replacing part of the compiled library as part of the test.

Module contents

Development Sub-Package

This package is used for development, testing and release purposes. It does not contain core functionality of pywincffi and is unused by pywincffi.core, pywincffi.kernel32 and other similar modules.