Skip to content

Commit

Permalink
Modify generator to move autogenerated test to tests folder (#2804)
Browse files Browse the repository at this point in the history
* move generated tests_schemapi to tests folder

* import absolute since test is now in tests folder

* re-ran generate_schema_wrapper.py
  • Loading branch information
mattijn committed Jan 4, 2023
1 parent 88b706f commit 1d90aec
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions altair/utils/schemapi.py
Expand Up @@ -621,13 +621,12 @@ def __get__(self, obj, cls):
f"\n\n {altair_prop.__doc__[attribute_index:]}"
)
)
# For short docsstrings such as Aggregate, Stack, et
# For short docstrings such as Aggregate, Stack, et
else:
self.__doc__ = (
altair_prop.__doc__.replace(" ", "") + "\n" + self.__doc__
)
# Add signatures and tab completion for the method and parameter names
# Currently works for `alt.X.bin` but not alt.X().bin`
self.__signature__ = inspect.signature(altair_prop)
self.__wrapped__ = inspect.getfullargspec(altair_prop)
self.__name__ = altair_prop.__name__
Expand All @@ -645,7 +644,9 @@ def __call__(self, *args, **kwargs):


def with_property_setters(cls):
"""Decorator to add property setters to a Schema class."""
"""
Decorator to add property setters to a Schema class.
"""
schema = cls.resolve_references()
for prop, propschema in schema.get("properties", {}).items():
setattr(cls, prop, _PropertySetter(prop, propschema))
Expand Down
1 change: 1 addition & 0 deletions altair/vegalite/v5/schema/channels.py
Expand Up @@ -91,6 +91,7 @@ def to_dict(self, validate=True, ignore=(), context=None):
ignore=ignore,
context=context)


@with_property_setters
class Angle(FieldChannelMixin, core.FieldOrDatumDefWithConditionMarkPropFieldDefnumber):
"""Angle schema wrapper
Expand Down
4 changes: 2 additions & 2 deletions tools/generate_schema_wrapper.py
Expand Up @@ -248,7 +248,7 @@ def download_schemafile(library, version, schemapath, skip_download=False):

def copy_schemapi_util():
"""
Copy the schemapi utility and its test file into altair/utils/
Copy the schemapi utility into altair/utils/ and its test file to tests/utils/
"""
# copy the schemapi utility file
source_path = abspath(join(dirname(__file__), "schemapi", "schemapi.py"))
Expand All @@ -267,7 +267,7 @@ def copy_schemapi_util():
join(dirname(__file__), "schemapi", "tests", "test_schemapi.py")
)
destination_path = abspath(
join(dirname(__file__), "..", "altair", "utils", "tests", "test_schemapi.py")
join(dirname(__file__), "..", "tests", "utils", "tests", "test_schemapi.py")
)

print("Copying\n {}\n -> {}".format(source_path, destination_path))
Expand Down
2 changes: 1 addition & 1 deletion tools/schemapi/tests/test_schemapi.py
Expand Up @@ -7,7 +7,7 @@

import numpy as np

from ..schemapi import (
from altair.utils.schemapi import (
UndefinedType,
SchemaBase,
Undefined,
Expand Down

0 comments on commit 1d90aec

Please sign in to comment.