-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fix block.py and add test for file block.py #25
base: master
Are you sure you want to change the base?
Conversation
For Block class: Add docstrings for functions in block.py Fix references to attribute so all self.type not split between self.type and self.id Add id property to maintain backwards compatibility type and data are always integers and should be treated as such in __repr__ As __cmp__ no longer in Python 3 need to use functools.total_ordering which is in 2.7 and 3.* https://docs.python.org/2/library/functools.html#functools.total_ordering https://docs.python.org/3/library/functools.html#functools.total_ordering Define __eq__ and __lt__ and others are created automatically For blockType enumeration: Move to back ported IntEnum as allows direct integer comparison https://pypi.python.org/pypi/enum34 https://docs.python.org/3/library/enum.html#intenum Add test_block.py: A unit test module to test the block file
Why are blocks orderable? Does some odd bit of the API depend on this? :s |
Don't have to orderable as far as I am aware but they had been defined as such with |
Until enum34 package defined in Travis, build will fail see #23 as enum won't exist. |
I don't think nonsensical orderings are helpful - will look to see if it's actually used anywhere (I hope not...) |
for index, attr in enumerate(b): | ||
self.assertEqual(attr, idAndData[index]) | ||
|
||
def testBlockConstants(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be alone here, but I'm unconvinced by the value of testing constants - persuade me...?
Testing that the name exists as well as the value in this case with enum. |
This reverts commit ff8a464. Oops, it's a python package not a deb!
block.data = The variant of the type of block. | ||
For example the colour of wool or the orientation of stairs | ||
The default type for blocks is dirt | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the indentation change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is unnecessary, can you keep the indentation of docstrings to one level in line with PEP 257 please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghickman Got the pep8/flake8 skillz to add this to tests so you don't need to keep hand-PEPing? ;P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unintentional will alter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hashbangstudio – Thanks!
This should hopefully mean that build will pass with enum dependency met
def __eq__(self, rhs): | ||
""" | ||
Equality override | ||
Two blocks are equal only if their hashes are equal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except that's only true in this case where hash
doesn't collide, and not generally true - would you mind making a proper __eq__
please?
Fix __eq__ so block only equal if all attributes equal Fix apostrophe usage
Move to PEP8 lowercase_name method names Move test of water and lava aliases out to separate test
Add function (self): that was left missing blockType changed to BlockType
Change functions and variables to lower_case
|
||
|
||
class blockType(Enum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this changes a bit of the API we don't want to change, but we aren't testing thoroughly enough :s
It will need to be changed for PEP8 naming and can't see where it is used in the rest of the API at the moment, unless I am just not seeing it. Can drop it from PR if it is used somewhere. |
Remove unittest style file Add py.test style file
Variable missed in conversion to PEP8 standards Change variable name to avoid confusion between withData(data) and the Block(type, data) created instances
Add comparison test using eval(repr()) Change to comparing against a constant string
So, sorry about this, but I had to revert a bunch of other changes to fix compatibility breakages they introduced. Are you ok to fix the merge conflicts here, or would you like a hand? Cheers, apologies! |
Will have a look to see if can fix conflicts over the weekend, if not will let you know |
Awesome, thanks, sorry again! |
both added test_block.py. Combined in one file
Add BlockType enum back in Maintain backwards compatibility
<3 thanks for the fixes! |
For example grass, sand, dirt or wool | ||
block.data = The variant of the type of block. | ||
For example the colour of wool or the orientation of stairs | ||
The default type for blocks is dirt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm a bit too keen on building obsidian houses, but I'm personally very wary about introducing defaults for what is a somewhat arbitrary choice...
remove docstring comment on default type
Agree is arbitrary, was left in from previous API refactoring. Have removed default assignment. |
For Block class:
Add docstrings for functions in block.py
Fix references to attribute so all self.type not split between self.type and self.id
Add id property to maintain backwards compatibility
type and data are always integers and should be treated as such in
__repr__
As
__cmp__
no longer in Python 3 need to use functools.total_ordering which is in 2.7 and 3.*https://docs.python.org/2/library/functools.html#functools.total_ordering
https://docs.python.org/3/library/functools.html#functools.total_ordering
Define
__eq__
and__lt__
and others are created automaticallyFor blockType enumeration:
Move to back ported IntEnum as allows direct integer comparison
https://pypi.python.org/pypi/enum34
https://docs.python.org/3/library/enum.html#intenum
Add test_block.py:
A unit test module to test the block file