Coder Social home page Coder Social logo

Use lazy_static about tox HOT 4 CLOSED

tox-rs avatar tox-rs commented on May 24, 2024
Use lazy_static

from tox.

Comments (4)

kurnevsky avatar kurnevsky commented on May 24, 2024 1

I'd prefer to use consts. In this case we can change time type from Instant to SystemTime and in tests set this time manually to the past like it was done in onion. It's simpler than this magic with lazy static. And one more benefit - SystemTime is more precise than Instant:

Note, however, that instants are not guaranteed to be steady. In other words, each tick of the underlying clock may not be the same length (e.g. some seconds may be longer than others). An instant may jump forwards or experience time dilation (slow down or speed up), but it will never go backwards.

from tox.

kurnevsky avatar kurnevsky commented on May 24, 2024

One thing that came to my mind - we can define different constants for tests and real code, using cfg attribute:

#[cfg(not(test))]
const MY_CONST: u32 = 1;
#[cfg(test)]
const MY_CONST: u32 = 123;

from tox.

kpp avatar kpp commented on May 24, 2024

Do we need this issue anymore?

from tox.

kurnevsky avatar kurnevsky commented on May 24, 2024

It depends. We still have these values as variables in config, and it's better to refactor it and change them to consts.

from tox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.