Ad
  • Custom User Avatar

    You commented out the first occurrence but not the second occurrence.

  • Custom User Avatar
    test.expect(default2 > now2 > default > now, msg)
    TypeError: '>' not supported between instances of 'NoneType' and 'datetime.datetime'
    

    Where so? in the samplet tests, I guess? Then you're(were) using an outdated version of the sample tests: I commented out that test in both the sample tests and the full test suite ages ago.

  • Custom User Avatar

    I want to continue this discussion.

    I also kept getting the same error:

        test.expect(default2 > now2 > default > now, msg)
    TypeError: '>' not supported between instances of 'NoneType' and 'datetime.datetime'
    

    And after expanding the further comments, it is revealed that the test contains:

    field2 = DateTimeField(auto_now=True, blank=True)
    default = field2.default
    

    This feels out of scope, since DateTimeField shouldn't be accessed outside a class. I had to put in extra hacks in my solution to get this to work.

  • Custom User Avatar

    Informational question only: Will descriptors work in place of metaclasses here? I understand the purpose of the kata is to learn metaclasses.

  • Custom User Avatar

    removed => isinstance is now allowed

  • Custom User Avatar
  • Custom User Avatar

    handled, testing only at Model instantiation time. Oh, I forgot to talk about default taking precedence over auto_now. I'll add that in the next fork.

  • Custom User Avatar

    suppressed the meaningless requirement (and updated the description)

  • Default User Avatar

    Thanks again for the feedback and the time you spent on this! I did have to check my validation, probably have to refactor it later.

  • Default User Avatar

    Tests passed! Thanks for modifying the tests! Really helped a lot!

  • Default User Avatar

    Thanks for looking into it and spending the time! I really appreciate it. I will look into to checking your comment on the DatetimeField.

  • Custom User Avatar

    I updated the tests so that the error message tells what fields are incorrect. Please reset the trainer and reload the page (don't forget to copy your current code first).

  • Custom User Avatar

    I just tried your code: you're actually looking at the wrong field (dunno why). Your code fails on instances where the DateTimeField is wrong, not the IntegerField.

  • Default User Avatar

    Noted and already done! It failing on the integer field in every case. Since the validation in the User class should have access to both the Integerfield and the data for it, I have checked it more than once.

    This is what my logs look like before they fail

    '''

    • model validation fields: {'char_': <solution.CharField object at 0x7f45c1367a50>, 'email_': <solution.EmailField object at 0x7f45c1367b10>, 'bool_': <solution.BooleanField object at 0x7f45c1367c10>, 'date_': <solution.DateTimeField object at 0x7f45c13677d0>, 'int_': <solution.IntegerField object at 0x7f45c1367790>}
    • initial_data: {'char_': False, 'email_': None, 'bool_': True, 'date_': datetime.datetime(2003, 9, 10, 0, 0), 'int_': None}
    • <solution.IntegerField object at 0x7f45c1367790>
    • int value: None
    • field args: {'default': None, 'blank': True, 'min_value': -100, 'max_value': 100}
    • value type <class 'NoneType'>

    '''

    Test response in this case with "Validation should have failed" while in previous cases with similiar data of None and fields args, it allows it

  • Custom User Avatar

    note: double check what is the actual field: you don't provide the info, so I bet one case uses an IntegerField while the other is a BooleanField or something else.

  • Loading more items...