Giter Club home page Giter Club logo

Comments (3)

thijstriemstra avatar thijstriemstra commented on June 3, 2024

smbus2 uses os.open to open the device, something that pyfakefs does not support: https://github.com/jmcgeheeiv/pyfakefs/blob/b7fc0b4d0c4d2a32197aa27ac48b30b2dca39f75/fake_filesystem_test.py#L867

from luma.core.

thijstriemstra avatar thijstriemstra commented on June 3, 2024

For example:

====================================================================== FAILURES =======================================================================
_____________________________________________________________ test_init_device_not_found ______________________________________________________________

    def test_init_device_not_found():
        from pyfakefs import fake_filesystem
        fs = fake_filesystem.FakeFilesystem()
        os_module = fake_filesystem.FakeOsModule(fs)
        pathname = '/dev/i2c-200'
        new_file = fs.CreateFile(pathname)
    
        port = 200
        address = 0x710
        with patch('smbus2.smbus2.os', os_module):
            with pytest.raises(luma.core.error.DeviceNotFoundError) as ex:
>               i2c(port=port, address=address)

tests/test_i2c.py:43: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
luma/core/serial.py:60: in __init__
    self._bus = bus or smbus2.SMBus(port)
.tox/py35/lib/python3.5/site-packages/smbus2/smbus2.py:132: in __init__
    self.open(bus)
.tox/py35/lib/python3.5/site-packages/smbus2/smbus2.py:142: in open
    self.fd = os.open("/dev/i2c-{}".format(bus), os.O_RDWR)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <pyfakefs.fake_filesystem.FakeOsModule object at 0x7fb266422cf8>, file_path = '/dev/i2c-200', flags = 2, mode = None

    def open(self, file_path, flags, mode=None):
        """Return the file descriptor for a FakeFile.
    
            WARNING: This implementation only implements creating a file. Please fill
            out the remainder for your needs.
    
            Args:
              file_path: the path to the file
              flags: low-level bits to indicate io operation
              mode: bits to define default permissions
    
            Returns:
              A file descriptor.
    
            Raises:
              OSError: if the path cannot be found
              ValueError: if invalid mode is given
              NotImplementedError: if an unsupported flag is passed in
            """
        if flags & os.O_CREAT:
            fake_file = FakeFileOpen(self.filesystem)(file_path, 'w')
            if mode:
                self.chmod(file_path, mode)
            return fake_file.fileno()
        else:
>           raise NotImplementedError('FakeOsModule.open')
E           NotImplementedError: FakeOsModule.open

.tox/py35/lib/python3.5/site-packages/pyfakefs/fake_filesystem.py:2595: NotImplementedError

from luma.core.

thijstriemstra avatar thijstriemstra commented on June 3, 2024

I'll create a wrapper for FakeOsModule.

from luma.core.

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.