You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

cppython

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cppython - pypi Package Compare versions

Comparing version
0.7.1.dev28
to
0.7.1.dev29
+49
tests/unit/test_interface.py
"""Tests the click interface type"""
from click.testing import CliRunner
from cppython.console.interface import cli
class TestInterface:
"""Various tests for the click interface"""
def test_info(self, cli_runner: CliRunner) -> None:
"""Verifies that the info command functions with CPPython hooks
Args:
cli_runner: The click runner
"""
result = cli_runner.invoke(cli, ["info"], catch_exceptions=False)
assert result.exit_code == 0
def test_list(self, cli_runner: CliRunner) -> None:
"""Verifies that the list command functions with CPPython hooks
Args:
cli_runner: The click runner
"""
result = cli_runner.invoke(cli, ["list"], catch_exceptions=False)
assert result.exit_code == 0
def test_update(self, cli_runner: CliRunner) -> None:
"""Verifies that the update command functions with CPPython hooks
Args:
cli_runner: The click runner
"""
result = cli_runner.invoke(cli, ["update"], catch_exceptions=False)
assert result.exit_code == 0
def test_install(self, cli_runner: CliRunner) -> None:
"""Verifies that the install command functions with CPPython hooks
Args:
cli_runner: The click runner
"""
result = cli_runner.invoke(cli, ["install"], catch_exceptions=False)
assert result.exit_code == 0
"""Tests the Project type"""
from pathlib import Path
import tomlkit
from cppython_core.schema import ProjectConfiguration
from pytest import FixtureRequest
from pytest_cppython.mock.interface import MockInterface
from cppython.project import Project
class TestProject:
"""Various tests for the project object"""
def test_default_construction(self, request: FixtureRequest) -> None:
"""The project type should be constructable without pyproject.toml support.
The CPPython project uses a working pyproject.toml file, and this file is used as the test data
Args:
request: The pytest request fixture
"""
# Use the CPPython directory as the test data
file = request.config.rootpath / "pyproject.toml"
project_configuration = ProjectConfiguration(pyproject_file=file, version=None)
interface = MockInterface()
pyproject_data = tomlkit.loads(file.read_text(encoding="utf-8"))
project = Project(project_configuration, interface, pyproject_data)
assert project
def test_missing_project_table(self, tmp_path: Path) -> None:
"""The project type should be constructable without the top level table
Args:
tmp_path: Temporary directory for dummy data
"""
file_path = tmp_path / "pyproject.toml"
with open(file_path, "a", encoding="utf8") as file:
file.write("")
project_configuration = ProjectConfiguration(pyproject_file=file_path, version=None)
interface = MockInterface()
project = Project(project_configuration, interface, {})
assert project
+23
-7

@@ -75,4 +75,5 @@ """A click CLI for CPPython interfacing

@click.option("-v", "--verbose", count=True, help="Print additional output")
@click.option("--debug/--no-debug", default=False)
@pass_config
def cli(config: Configuration, verbose: int) -> None:
def cli(config: Configuration, verbose: int, debug: bool) -> None:
"""entry_point group for the CLI commands

@@ -83,9 +84,11 @@

verbose: The verbosity level
debug: Debug mode
"""
config.configuration.verbosity = verbose
config.configuration.debug = debug
@cli.command()
@cli.command(name="info")
@pass_config
def info(config: Configuration) -> None:
def info_command(config: Configuration) -> None:
"""Prints project information

@@ -101,5 +104,18 @@

@cli.command()
@cli.command(name="list")
@pass_config
def install(config: Configuration) -> None:
def list_command(config: Configuration) -> None:
"""Prints project information
Args:
config: The CLI configuration object
"""
version = config.query_scm()
config.logger.info("The SCM project version is: %s", version)
@cli.command(name="install")
@pass_config
def install_command(config: Configuration) -> None:
"""Install API call

@@ -114,5 +130,5 @@

@cli.command()
@cli.command(name="update")
@pass_config
def update(config: Configuration) -> None:
def update_command(config: Configuration) -> None:
"""Update API call

@@ -119,0 +135,0 @@

@@ -11,2 +11,3 @@ """Manages data flow to and from plugins

from cppython_core.schema import CoreData, Interface, ProjectConfiguration, PyProject
from pydantic import ValidationError

@@ -36,36 +37,46 @@ from cppython.builder import Builder

if (pyproject := PyProject(**pyproject_data)) is None:
raise ConfigError("PyProject data is not defined")
try:
if (pyproject := PyProject(**pyproject_data)) is None:
raise ConfigError("Table [project] is not defined")
if pyproject.tool is None:
raise ConfigError("Table [tool] is not defined")
if pyproject.tool is None:
raise ConfigError("Table [tool] is not defined")
if pyproject.tool.cppython is None:
raise ConfigError("Table [tool.cppython] is not defined")
if pyproject.tool.cppython is None:
raise ConfigError("Table [tool.cppython] is not defined")
builder = Builder(self.logger)
builder = Builder(self.logger)
self._core_data = builder.generate_core_data(configuration, pyproject.project, pyproject.tool.cppython)
self._core_data = builder.generate_core_data(configuration, pyproject.project, pyproject.tool.cppython)
raw_generator_plugins = builder.find_generators()
generator_plugins = builder.filter_plugins(
raw_generator_plugins,
self.core_data.project_data.pyproject_file.parent,
self.core_data.cppython_data.generator_name,
"Generator",
)
raw_generator_plugins = builder.find_generators()
generator_plugins = builder.filter_plugins(
raw_generator_plugins,
self.core_data.project_data.pyproject_file.parent,
self.core_data.cppython_data.generator_name,
"Generator",
)
raw_provider_plugins = builder.find_providers()
provider_plugins = builder.filter_plugins(
raw_provider_plugins,
self.core_data.project_data.pyproject_file.parent,
self.core_data.cppython_data.provider_name,
"Provider",
)
raw_provider_plugins = builder.find_providers()
provider_plugins = builder.filter_plugins(
raw_provider_plugins,
self.core_data.project_data.pyproject_file.parent,
self.core_data.cppython_data.provider_name,
"Provider",
)
generator_type, provider_type = builder.solve(generator_plugins, provider_plugins)
generator_type, provider_type = builder.solve(generator_plugins, provider_plugins)
self._generator = builder.create_generator(self.core_data, pyproject.tool.cppython.generator, generator_type)
self._provider = builder.create_provider(self.core_data, pyproject.tool.cppython.provider, provider_type)
self._generator = builder.create_generator(
self.core_data, pyproject.tool.cppython.generator, generator_type
)
self._provider = builder.create_provider(self.core_data, pyproject.tool.cppython.provider, provider_type)
except ConfigError:
logging.exception("Unhandled configuration. CPPython will process no further")
return
except ValidationError as error:
logging.error(error)
return
self._enabled = True

@@ -72,0 +83,0 @@

Metadata-Version: 2.1
Name: cppython
Version: 0.7.1.dev28
Version: 0.7.1.dev29
Summary: A Python management solution for C++ dependencies

@@ -5,0 +5,0 @@ License: MIT

@@ -19,3 +19,3 @@ [project]

]
version = "0.7.1.dev28"
version = "0.7.1.dev29"

@@ -31,2 +31,4 @@ [project.license-files]

[project.optional-dependencies]
[project.entry-points."cppython.scm"]

@@ -51,2 +53,3 @@ cmake = "cppython.plugins.git:GitSCM"

"pytest-cov>=3.0.0",
"pytest-click>=1.1",
"pytest-mock>=3.8.2",

@@ -53,0 +56,0 @@ "pytest-cppython>=0.2.0.dev0",