Ad
  • Custom User Avatar

    Kata suggestions are meant to suggest improvements on the kata, you should use question label instead.

    Based on your latest code, I get this error --> TypeError: Opsys.create is not a constructor. Clearly, you are not instantiating the class correctly and everything should be placed in the constructor (including the version) and major, minor && patch values.

  • Custom User Avatar

    OP solved it, closing. Based on the error message, seems like you are trying to parse a non-digit character into integer

  • Custom User Avatar

    Really sorry, I didn't know that I had tried to attempt this kata a long period back.
    That code was mine actually :/
    My bad!

    Thanks for the reply!

  • Custom User Avatar

    The initial solution in python does not have any function body for __init__, I'm not sure where you're getting that from.

    That said, you should never raise a BaseException. The exact exception type doesn't matter for this kata, but it should be a concrete type, not the base class. Try raise ValueError(...), it will fix your issue.

  • Custom User Avatar

    Hi!
    The author has given the following code in the object constructor in the Python Solution's preloaded code:

    try:
      # parse the string
    except Exception:
      raise BaseException("Error occured while parsing version!")
    

    Now my solution works for all the fixed tests, however Test 7 Exception Calls is just not passing :c
    I'm handling the rollback error as well
    But it's stopping at the error I've just written above in the code.

    What could be the issue?

    P.S. I'm getting this error:

    Traceback (most recent call last):
      File "/workspace/default/solution.py", line 14, in __init__
        self.maj = int(v[0])
                   ^^^^^^^^^
    ValueError: invalid literal for int() with base 10: 'a'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/workspace/default/tests.py", line 4, in <module>
        @test.describe("Sample tests")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 112, in wrapper
        func()
      File "/workspace/default/tests.py", line 50, in sample_tests
        @test.it("Exception calls")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 112, in wrapper
        func()
      File "/workspace/default/tests.py", line 53, in it_7
        VersionManager("a.b.c")
      File "/workspace/default/solution.py", line 20, in __init__
        raise BaseException("Error occured while parsing version!")
    BaseException: Error occured while parsing version!
    

    I'd appreciate your help!

  • Custom User Avatar

    I'm getting a critical error when testing exceptions cases, in my code i'm calling "throw VersionException("Error occured while parsing version!");"
    without knowing how VersionException is defined i dont realize what is happening, any clue? thanks in advance

    log:
    UndefinedBehaviorSanitizer:DEADLYSIGNAL
    ==1==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f4f4e314afc bp 0x000002994ed0 sp 0x7ffc95d256b8 T1)
    ==1==The signal is caused by a READ memory access.
    ==1==Hint: address points to the zero page.
    ==1==WARNING: invalid path to external symbolizer!
    ==1==WARNING: Failed to use and restart external symbolizer!
    #0 0x7f4f4e314afb (/lib/x86_64-linux-gnu/libc.so.6+0x18eafb)
    #1 0x7f4f4ecf37dc (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0x13d7dc)
    #2 0x42e4e2 (/workspace/test+0x42e4e2)
    #3 0x428f1e (/workspace/test+0x428f1e)
    #4 0x4288bd (/workspace/test+0x4288bd)
    #5 0x4285ab (/workspace/test+0x4285ab)
    #6 0x431735 (/workspace/test+0x431735)
    #7 0x427b8d (/workspace/test+0x427b8d)
    #8 0x7f4f4e1a7c86 (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
    #9 0x404be9 (/workspace/test+0x404be9)

    UndefinedBehaviorSanitizer can not provide additional info.
    ==1==ABORTING

  • Custom User Avatar

    Hi!

    The Random tests returns:
    new VersionManager("47.40.22").patch().rollback().minor().minor().rollback().patch().major().major() ==> expected: <49.0.0> but was: <2.0.0>

    but when I execute this code in local mode, it returns the correct and expected result <49.0.0>.

    Could you help me, please? Thanks!

  • Custom User Avatar

    I added some more assertions in sample and fixed tests which should show where your solution fails.

  • Custom User Avatar

    The problem is that since all the version methods operate on the same instance, rollback() also should alter the VersionManager instance. Your solution returns another instance on rollback() which works with chaining but not with separate method call like the random tests are performing.

  • Custom User Avatar

    It's difficult to tell what is wrong with your solution without seeing your solution.

  • Custom User Avatar

    Because it's returning the expected value (<51.0.0>), not the value that the "randomTests" method is telling that it's returning (<51.1.0>)

  • Custom User Avatar

    But how do you know that your local test is correct?

    It's difficult to tell what is wrong with your solution without seeing your solution.

  • Custom User Avatar

    Hi,

    The "randomTests" method of "VersionManagerTest" class (VersionManagerTest.randomTests(VersionManagerTest.java:159)) has some issue because is returning errors like:

    "org.opentest4j.AssertionFailedError: new VersionManager("50").minor().major().minor().rollback() ==> expected: <51.0.0> but was: <51.1.0>"

    but when I execute that code in local it returns the correct and expected result (in this case <51.0.0>), so it shouldn't be returning that error.

    Could you have a look please? Thx!

  • Custom User Avatar

    Should be fixed.

  • Custom User Avatar

    for throw exception you just need to type "throw VersionException("Error occured while parsing version!");"
    because it already have built-in VersionException Class for tester. Means to submit you dont have to use try and catch block. I hope my explaination is clear, sorry for my broken english

  • Loading more items...