0

I am trying to adapt a code from windows to macOS for some automation with python and selenium where an assertion between 2 dates is performed. On windows everything works as expected , but same code is not working when running it on macOS.

Here is the code during debugging(with values for api_date and api_processed_date):

api_date = response.json()['current_version']['file']['created'][:10] api_date: 2021-06-02 00:00:00
# process the date to have the same format as in frontend
api_date = datetime.strptime(api_date, '%Y-%m-%d')
api_processed_date = datetime.strftime(api_date, "%b %#d, %Y") api_processed_date: "Jun #d 2021" 
# verify info displayed in page
page = Versions(selenium, base_url)
selenium.get(f'{base_url}/addon/{variables["addon_version_install"]}/versions/')
assert page.versions_list[0].version_number == addon_version
assert addon_size == page.versions_list[0].version_size
assert page.versions_list[0].released_date == api_processed_date

Any idea how to modify this to work on MacOS?

Thanks

I expect that the last assertion to be true

  • https://stackoverflow.com/questions/25317270/what-are-the-differences-in-pythons-time-clock-in-mac-vs-windows – Allanckw Jul 17 '23 at 17:28
  • 1
    Does this answer your question? [What are the differences in Pythons time.clock() in Mac vs Windows?](https://stackoverflow.com/questions/25317270/what-are-the-differences-in-pythons-time-clock-in-mac-vs-windows) – Mark Jul 17 '23 at 17:38
  • 1
    It's impossible to guess what's going on because the comparison depends on the missing `Versions` method. It's far more likely that the *data* is different, or because of locale differences, `strftime` created a different string. Or `Versions` doesn't produce what you expected it to. – Panagiotis Kanavos Jul 17 '23 at 18:10
  • @Allanckw and @Mark, What does `time.clock()` have to do with this question? Nowhere in the example is `time.clock()` used. – Kurtis Rader Jul 17 '23 at 19:51
  • 1
    What @PanagiotisKanavos said. Also, on line 4 you have `api_processed_date: "Jun #d 2021"` (note the `#d`). You example is missing too much important detail for us to even guess what the problem is. Heck, just showing us the two values that are unexpectedly different is likely to shed light on the problem. – Kurtis Rader Jul 17 '23 at 19:53
  • api_processed_date = datetime.strftime(api_date, "%b %#d, %Y") # For Windows api_processed_date = datetime.strftime(api_date, "%b %e, %Y") # For macOS. Just use condition based on the OS type. – Samira Kumar Nanda Jul 18 '23 at 08:58
  • @SamiraKumarNanda - thanks!! that worked for me!! – Victor Carciu Jul 18 '23 at 10:09

0 Answers0