-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Loader #65
Open
angelsanzn
wants to merge
20
commits into
nestorsalceda:master
Choose a base branch
from
angelsanzn:refactor-loader
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Refactor Loader #65
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The subject of an example group is either a class object or a string. The latter is only the case when the call to `getattr` returns the default vaule (the third argument given in the call). Hence we can chop the string just there instead of checking it later.
to `_methods_in` for consistency with similar methods
_example_groups_for -> _top_level_classes_in: at the beginning, top-level classes are extracted, from either module objects or class objects themselves (in the case of nested examples). But they are not example groups yet. _is_example_group -> _is_name_of_example_group: the parameter is expected to be a string, hence it's not really a candidate for an example group. It's a name of something, and the method determines whether that something is an example group. _is_hook -> _is_name_of_hook: same as above.
…he code The fact that these classes are nested within klass is reflected in the call to _top_level_classes_in(klass).
This gives that method more symmetry with respect to the all other operations in the class. This also extracts another method from the extracted method, for more clearly stating what a helper method is.
…xecution_context` and bury Python version check
This delimits the boundary of the 'dichotomy' between classes and example groups, and makes all related query methods in the class have a similar signature.
The name of the method being called is more descriptive.
This also makes it a bit more explicit that instantiating an ExampleGroup doesn't add examples, hooks or nested examples to it.
a class, not an example group
This makes the remaining ones match the signatures of the previously refactored ones: since we're looking at the name, receive only the name, and make that clear in the name of the method.
This makes clearer that this method doesn't return `Example`s but methods, which it uses to create the `Example`s.
This is unnecessary because _create_bare_example_group only takes two parameters and it's almost always called with an explicit second parameter.
This is the way the other methods querying names are naming their parameters. The fact that it's the name of a class is irrelvant to `_is_name_of_example_group`.
angelsanzn
force-pushed
the
refactor-loader
branch
from
February 5, 2016 00:45
67d555e
to
c7f9170
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Again, some refactors I noticed while reading the code.
This mostly boils down to:
The commit messages are more detailed.
Some of this might be a matter of personal taste (especially the naming), so I'm open to changes ;)