mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-07 04:34:29 +08:00
new semanal wip 1
This commit is contained in:
0
pytest_plugin/__init__.py
Normal file
0
pytest_plugin/__init__.py
Normal file
41
pytest_plugin/collect.py
Normal file
41
pytest_plugin/collect.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# noinspection PyUnresolvedReferences
|
||||
from pytest_mypy.collect import File, YamlTestFile, pytest_addoption
|
||||
from pytest_mypy.item import YamlTestItem
|
||||
|
||||
|
||||
class DjangoYamlTestFile(YamlTestFile):
|
||||
def get_test_class(self):
|
||||
return NewSemanalDjangoTestItem
|
||||
|
||||
|
||||
def pytest_collect_file(path, parent):
|
||||
if path.ext in {'.yaml', '.yml'} and path.basename.startswith(('test-', 'test_')):
|
||||
return DjangoYamlTestFile(path, parent=parent, config=parent.config)
|
||||
|
||||
|
||||
class NewSemanalDjangoTestItem(YamlTestItem):
|
||||
def custom_init(self):
|
||||
settings = {
|
||||
'SECRET_KEY': '"1"',
|
||||
}
|
||||
additional_settings = self.parsed_test_data.get('additional_settings')
|
||||
if additional_settings:
|
||||
for item in additional_settings:
|
||||
name, _, val = item.partition('=')
|
||||
settings[name] = val
|
||||
|
||||
installed_apps = self.parsed_test_data.get('installed_apps')
|
||||
if installed_apps:
|
||||
installed_apps_as_str = '(' + ','.join([repr(app) for app in installed_apps]) + ',)'
|
||||
|
||||
pyproject_toml_file = File(path='pyproject.toml',
|
||||
content='[tool.django-stubs]\ndjango_settings_module=\'mysettings\'')
|
||||
self.files.append(pyproject_toml_file)
|
||||
|
||||
settings_contents = f'INSTALLED_APPS={installed_apps_as_str}\n'
|
||||
settings_contents += '\n'.join([f'{key}={val}' for key, val in settings.items()])
|
||||
|
||||
mysettings_file = File(path='mysettings.py', content=settings_contents)
|
||||
self.files.append(mysettings_file)
|
||||
|
||||
|
||||
42
pytest_plugin/setup.py
Normal file
42
pytest_plugin/setup.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import sys
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
# with open('README.md', 'r') as f:
|
||||
# readme = f.read()
|
||||
|
||||
dependencies = [
|
||||
# 'pytest-mypy-plugins',
|
||||
# 'mypy',
|
||||
# 'decorator',
|
||||
# 'capturer'
|
||||
]
|
||||
# if sys.version_info[:2] < (3, 7):
|
||||
# # dataclasses port for 3.6
|
||||
# dependencies += ['dataclasses']
|
||||
|
||||
setup(
|
||||
name='pytest-django-stubs-newsemanal',
|
||||
version='0.4.0',
|
||||
# description='pytest plugin for writing tests for mypy plugins',
|
||||
# long_description=readme,
|
||||
# long_description_content_type='text/markdown',
|
||||
license='MIT',
|
||||
url="https://github.com/mkurnikov/pytest-mypy-plugins",
|
||||
author="Maksim Kurnikov",
|
||||
author_email="maxim.kurnikov@gmail.com",
|
||||
# packages=['pytest_plugin'],
|
||||
# the following makes a plugin available to pytest
|
||||
entry_points={
|
||||
'pytest11': [
|
||||
'pytest-django-stubs-newsemanal = pytest_plugin.collect'
|
||||
]
|
||||
},
|
||||
install_requires=dependencies,
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7'
|
||||
]
|
||||
)
|
||||
Reference in New Issue
Block a user